{"id":18804394,"url":"https://github.com/abates/gosh","last_synced_at":"2026-01-06T15:30:14.549Z","repository":{"id":27246900,"uuid":"30719012","full_name":"abates/gosh","owner":"abates","description":"A framework for building Shells in Go","archived":false,"fork":false,"pushed_at":"2015-03-04T02:11:09.000Z","size":260,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2024-12-29T20:42:26.799Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abates.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-12T19:16:23.000Z","updated_at":"2018-11-20T18:59:48.000Z","dependencies_parsed_at":"2022-07-25T17:22:06.814Z","dependency_job_id":null,"html_url":"https://github.com/abates/gosh","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abates%2Fgosh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abates%2Fgosh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abates%2Fgosh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abates%2Fgosh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abates","download_url":"https://codeload.github.com/abates/gosh/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239736802,"owners_count":19688520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T22:39:08.176Z","updated_at":"2026-01-06T15:30:12.485Z","avatar_url":"https://github.com/abates.png","language":"Go","readme":"# gosh version 0.0.1\n\nGosh is a simple package designed to make creating command line shells in go a\nlittle bit easier.  The concept is simple: have a command prompt with\nauto-completion and history that can execute commands written in go.  The\ncommands can be hierarchical, similar to the CLI in common network operating\nsystems.  The commands can also be more like traditional OS commands, with no\nhierarchy.\n\n## Examples\n\nA simple example of a single command shell:\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"github.com/abates/gosh\"\n)\n\ntype cmd string\n\nfunc (c cmd) Exec() error {\n  fmt.Printf(\"Executing %s\\n\", string(c))\n  return nil\n}\n\nvar commands = gosh.CommandMap{\n  \"cmd\": cmd(\"My Command!\"),\n}\n\nfunc main() {\n  shell := gosh.NewShell(commands)\n  shell.Exec()\n}\n```\n\nAny arguments that follow the command on the prompt are passed into the Exec\nmethod by way of the os.Args string slice.  The shell will initialize with a\ndefault line editor that implements history, auto-completion and the prompt\nstring.  \n\nThe default shell can be supplied with a customized prompter:\n\n```go\nfunc main() {\n  shell := gosh.NewShell(commands)\n  shell.SetPrompter(func() string {\n    return \"Custom Prompt\u003e \"\n  })\n  shell.Exec()\n}\n```\n\nCommands can optionally specify auto-completion candidates for their arguments:\n```go\ntype cmd string\n\nfunc (c cmd) Exec() error {\n  fmt.Printf(\"Executing %s\\n\", string(c))\n  return nil\n}\n\nfunc (c cmd) Completions(field string) []string {\n  return []string{\"arg1\", \"arg2\", \"arg3\"}\n}\n```\n\nCommand hierarchies can be created with the CommandTree struct:\n```go\nvar commands = gosh.CommandMap{\n  \"show\": gosh.NewTreeCommand(gosh.CommandMap{\n    \"interface\":  InterfaceCommand{},\n    \"interfaces\": InterfacesCommand{},\n    \"time\":       TimeCommand{},\n  }),\n}\n```\n\n## Documentation\nhttps://godoc.org/github.com/abates/gosh\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabates%2Fgosh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabates%2Fgosh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabates%2Fgosh/lists"}