{"id":13582257,"url":"https://github.com/abiosoft/ishell","last_synced_at":"2025-05-14T15:09:45.588Z","repository":{"id":34896508,"uuid":"38926460","full_name":"abiosoft/ishell","owner":"abiosoft","description":"Library for creating interactive cli applications.","archived":false,"fork":false,"pushed_at":"2023-10-08T14:18:25.000Z","size":150,"stargazers_count":1716,"open_issues_count":60,"forks_count":202,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-04-10T02:58:31.909Z","etag":null,"topics":["cli","cli-app","go","ishell","readline","shell"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abiosoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-07-11T13:23:42.000Z","updated_at":"2025-04-06T14:28:12.000Z","dependencies_parsed_at":"2023-10-20T16:16:04.739Z","dependency_job_id":null,"html_url":"https://github.com/abiosoft/ishell","commit_stats":{"total_commits":133,"total_committers":22,"mean_commits":6.045454545454546,"dds":0.3458646616541353,"last_synced_commit":"4f77a91e8ead313c7f416bcb391110bd8cc85556"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abiosoft%2Fishell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abiosoft%2Fishell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abiosoft%2Fishell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abiosoft%2Fishell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abiosoft","download_url":"https://codeload.github.com/abiosoft/ishell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248335876,"owners_count":21086673,"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":["cli","cli-app","go","ishell","readline","shell"],"created_at":"2024-08-01T15:02:32.487Z","updated_at":"2025-04-11T11:36:56.389Z","avatar_url":"https://github.com/abiosoft.png","language":"Go","readme":"# ishell\n\nishell is an interactive shell library for creating interactive cli applications.\n\n[![Go Reference](https://godocs.io/github.com/abiosoft/ishell/v2?status.svg)](https://godocs.io/github.com/abiosoft/ishell/v2)\n[![Go Report Card](https://goreportcard.com/badge/github.com/abiosoft/ishell)](https://goreportcard.com/report/github.com/abiosoft/ishell)\n\n## Usage\n\n```go\nimport \"strings\"\nimport \"github.com/abiosoft/ishell/v2\"\n\nfunc main(){\n    // create new shell.\n    // by default, new shell includes 'exit', 'help' and 'clear' commands.\n    shell := ishell.New()\n\n    // display welcome info.\n    shell.Println(\"Sample Interactive Shell\")\n\n    // register a function for \"greet\" command.\n    shell.AddCmd(\u0026ishell.Cmd{\n        Name: \"greet\",\n        Help: \"greet user\",\n        Func: func(c *ishell.Context) {\n            c.Println(\"Hello\", strings.Join(c.Args, \" \"))\n        },\n    })\n\n    // run shell\n    shell.Run()\n}\n```\n\nExecution\n\n```\nSample Interactive Shell\n\u003e\u003e\u003e help\n\nCommands:\n  clear      clear the screen\n  greet      greet user\n  exit       exit the program\n  help       display help\n\n\u003e\u003e\u003e greet Someone Somewhere\nHello Someone Somewhere\n\u003e\u003e\u003e exit\n$\n```\n\n### Reading input\n\n```go\n// simulate an authentication\nshell.AddCmd(\u0026ishell.Cmd{\n    Name: \"login\",\n    Help: \"simulate a login\",\n    Func: func(c *ishell.Context) {\n        // disable the '\u003e\u003e\u003e' for cleaner same line input.\n        c.ShowPrompt(false)\n        defer c.ShowPrompt(true) // yes, revert after login.\n\n        // get username\n        c.Print(\"Username: \")\n        username := c.ReadLine()\n\n        // get password.\n        c.Print(\"Password: \")\n        password := c.ReadPassword()\n\n        ... // do something with username and password\n\n        c.Println(\"Authentication Successful.\")\n    },\n})\n```\n\nExecution\n\n```\n\u003e\u003e\u003e login\nUsername: someusername\nPassword:\nAuthentication Successful.\n```\n\n### Multiline input\n\nBuiltin support for multiple lines.\n\n```\n\u003e\u003e\u003e This is \\\n... multi line\n\n\u003e\u003e\u003e Cool that \u003c\u003c EOF\n... everything here goes\n... as a single argument.\n... EOF\n```\n\nUser defined\n\n```go\nshell.AddCmd(\u0026ishell.Cmd{\n    Name: \"multi\",\n    Help: \"input in multiple lines\",\n    Func: func(c *ishell.Context) {\n        c.Println(\"Input multiple lines and end with semicolon ';'.\")\n        lines := c.ReadMultiLines(\";\")\n        c.Println(\"Done reading. You wrote:\")\n        c.Println(lines)\n    },\n})\n```\n\nExecution\n\n```\n\u003e\u003e\u003e multi\nInput multiple lines and end with semicolon ';'.\n\u003e\u003e\u003e this is user defined\n... multiline input;\nYou wrote:\nthis is user defined\nmultiline input;\n```\n\n### Keyboard interrupt\n\nBuiltin interrupt handler.\n\n```\n\u003e\u003e\u003e ^C\nInput Ctrl-C once more to exit\n\u003e\u003e\u003e ^C\nInterrupted\nexit status 1\n```\n\nCustom\n\n```go\nshell.Interrupt(func(count int, c *ishell.Context) { ... })\n```\n\n### Multiple Choice\n\n```go\nfunc(c *ishell.Context) {\n    choice := c.MultiChoice([]string{\n        \"Golangers\",\n        \"Go programmers\",\n        \"Gophers\",\n        \"Goers\",\n    }, \"What are Go programmers called ?\")\n    if choice == 2 {\n        c.Println(\"You got it!\")\n    } else {\n        c.Println(\"Sorry, you're wrong.\")\n    }\n},\n```\n\nOutput\n\n```\nWhat are Go programmers called ?\n  Golangers\n  Go programmers\n\u003e Gophers\n  Goers\n\nYou got it!\n```\n\n### Checklist\n\n```go\nfunc(c *ishell.Context) {\n    languages := []string{\"Python\", \"Go\", \"Haskell\", \"Rust\"}\n    choices := c.Checklist(languages,\n        \"What are your favourite programming languages ?\", nil)\n    out := func() []string { ... } // convert index to language\n    c.Println(\"Your choices are\", strings.Join(out(), \", \"))\n}\n```\n\nOutput\n\n```\nWhat are your favourite programming languages ?\n    Python\n  ✓ Go\n    Haskell\n \u003e✓ Rust\n\nYour choices are Go, Rust\n```\n\n### Progress Bar\n\nDeterminate\n\n```go\nfunc(c *ishell.Context) {\n    c.ProgressBar().Start()\n    for i := 0; i \u003c 101; i++ {\n        c.ProgressBar().Suffix(fmt.Sprint(\" \", i, \"%\"))\n        c.ProgressBar().Progress(i)\n        ... // some background computation\n    }\n    c.ProgressBar().Stop()\n}\n```\n\nOutput\n\n```\n[==========\u003e         ] 50%\n```\n\nIndeterminate\n\n```go\n\nfunc(c *ishell.Context) {\n    c.ProgressBar().Indeterminate(true)\n    c.ProgressBar().Start()\n    ... // some background computation\n    c.ProgressBar().Stop()\n}\n```\n\nOutput\n\n```\n[ ====               ]\n```\n\nCustom display using [briandowns/spinner](https://github.com/briandowns/spinner).\n\n```go\ndisplay := ishell.ProgressDisplayCharSet(spinner.CharSets[11])\nfunc(c *Context) { c.ProgressBar().Display(display) ... }\n\n// or set it globally\nishell.ProgressBar().Display(display)\n```\n\n### Durable history\n\n```go\n// Read and write history to $HOME/.ishell_history\nshell.SetHomeHistoryPath(\".ishell_history\")\n```\n\n### Non-interactive execution\n\nIn some situations it is desired to exit the program directly after executing a single command.\n\n```go\n// when started with \"exit\" as first argument, assume non-interactive execution\nif len(os.Args) \u003e 1 \u0026\u0026 os.Args[1] == \"exit\" {\n    shell.Process(os.Args[2:]...)\n} else {\n    // start shell\n    shell.Run()\n}\n```\n\n```bash\n# Run normally - interactive mode:\n$ go run main.go\n\u003e\u003e\u003e |\n\n# Run non-interactivelly\n$ go run main.go exit greet Someusername\nHello Someusername\n```\n\n### Output with Color\n\nYou can use [fatih/color](https://github.com/fatih/color).\n\n```go\nfunc(c *ishell.Context) {\n    yellow := color.New(color.FgYellow).SprintFunc()\n    c.Println(yellow(\"This line is yellow\"))\n}\n```\n\nExecution\n\n```sh\n\u003e\u003e\u003e color\nThis line is yellow\n```\n\n### Example\n\nAvailable [here](https://github.com/abiosoft/ishell/blob/master/example/main.go).\n\n```sh\ngo run example/main.go\n```\n\n## Supported Platforms\n\n- [x] Linux\n- [x] OSX\n- [x] Windows [Not tested but should work]\n\n## Note\n\nishell is in active development and can still change significantly.\n\n## Roadmap (in no particular order)\n\n- [x] Multiline inputs\n- [x] Command history\n- [x] Customizable tab completion\n- [x] Handle ^C interrupts\n- [x] Subcommands and help texts\n- [x] Scrollable paged output\n- [x] Progress bar\n- [x] Multiple choice prompt\n- [x] Checklist prompt\n- [x] Support for command aliases\n- [ ] Multiple line progress bars\n- [ ] Testing, testing, testing\n\n## Contribution\n\n1. Create an issue to discuss it.\n2. Send in Pull Request.\n\n## License\n\nMIT\n\n## Credits\n\n| Library                                                                        | Use                                    |\n| ------------------------------------------------------------------------------ | -------------------------------------- |\n| [github.com/flynn-archive/go-shlex](https://github.com/flynn-archive/go-shlex) | splitting input into command and args. |\n| [github.com/chzyer/readline](https://github.com/chzyer/readline)               | readline capabilities.                 |\n\n## Donate\n\n```\nbitcoin: 1GTHYEDiy2C7RzXn5nY4wVRaEN2GvLjwZN\npaypal: a@abiosoft.com\n```\n","funding_links":[],"categories":["Misc","Repositories","Go","CLI frameworks","cli"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabiosoft%2Fishell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabiosoft%2Fishell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabiosoft%2Fishell/lists"}