11# ishell
2+
23ishell is an interactive shell library for creating interactive cli applications.
34
45[ ![ Documentation] ( https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square )] ( https://godoc.org/github.com/abiosoft/ishell )
56[ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/abiosoft/ishell )] ( https://goreportcard.com/report/github.com/abiosoft/ishell )
67
7- ## Older version
8- The current master is not backward compatible with older version. Kindly change your import path to ` gopkg.in/abiosoft/ishell.v1 ` .
9-
10- Older version of this library is still available at [ https://gopkg.in/abiosoft/ishell.v1 ] ( https://gopkg.in/abiosoft/ishell.v1 ) .
11-
12- However, you are advised to upgrade to v2 [ https://gopkg.in/abiosoft/ishell.v2 ] ( https://gopkg.in/abiosoft/ishell.v2 ) .
13-
148## Usage
159
1610``` go
@@ -38,7 +32,9 @@ func main(){
3832 shell.Run ()
3933}
4034```
35+
4136Execution
37+
4238```
4339Sample Interactive Shell
4440>>> help
5652```
5753
5854### Reading input
55+
5956``` go
6057// simulate an authentication
6158shell.AddCmd (&ishell.Cmd {
@@ -80,7 +77,9 @@ shell.AddCmd(&ishell.Cmd{
8077 },
8178})
8279```
80+
8381Execution
82+
8483```
8584>>> login
8685Username: someusername
@@ -89,7 +88,9 @@ Authentication Successful.
8988```
9089
9190### Multiline input
91+
9292Builtin support for multiple lines.
93+
9394```
9495>>> This is \
9596... multi line
@@ -99,7 +100,9 @@ Builtin support for multiple lines.
99100... as a single argument.
100101... EOF
101102```
103+
102104User defined
105+
103106``` go
104107shell.AddCmd (&ishell.Cmd {
105108 Name : " multi" ,
@@ -112,7 +115,9 @@ shell.AddCmd(&ishell.Cmd{
112115 },
113116})
114117```
118+
115119Execution
120+
116121```
117122>>> multi
118123Input multiple lines and end with semicolon ';'.
@@ -122,16 +127,21 @@ You wrote:
122127this is user defined
123128multiline input;
124129```
130+
125131### Keyboard interrupt
132+
126133Builtin interrupt handler.
134+
127135```
128136>>> ^C
129137Input Ctrl-C once more to exit
130138>>> ^C
131139Interrupted
132140exit status 1
133141```
142+
134143Custom
144+
135145``` go
136146shell.Interrupt (func (count int , c *ishell.Context ) { ... })
137147```
@@ -153,7 +163,9 @@ func(c *ishell.Context) {
153163 }
154164},
155165```
166+
156167Output
168+
157169```
158170What are Go programmers called ?
159171 Golangers
@@ -163,7 +175,9 @@ What are Go programmers called ?
163175
164176You got it!
165177```
178+
166179### Checklist
180+
167181``` go
168182func (c *ishell .Context ) {
169183 languages := []string {" Python" , " Go" , " Haskell" , " Rust" }
@@ -173,7 +187,9 @@ func(c *ishell.Context) {
173187 c.Println (" Your choices are" , strings.Join (out (), " , " ))
174188}
175189```
190+
176191Output
192+
177193```
178194What are your favourite programming languages ?
179195 Python
@@ -185,7 +201,9 @@ Your choices are Go, Rust
185201```
186202
187203### Progress Bar
204+
188205Determinate
206+
189207``` go
190208func (c *ishell .Context ) {
191209 c.ProgressBar ().Start ()
@@ -197,12 +215,15 @@ func(c *ishell.Context) {
197215 c.ProgressBar ().Stop ()
198216}
199217```
218+
200219Output
220+
201221```
202222[==========> ] 50%
203223```
204224
205225Indeterminate
226+
206227``` go
207228
208229func (c *ishell .Context ) {
@@ -212,12 +233,15 @@ func(c *ishell.Context) {
212233 c.ProgressBar ().Stop ()
213234}
214235```
236+
215237Output
238+
216239```
217240[ ==== ]
218241```
219242
220243Custom display using [ briandowns/spinner] ( https://github.com/briandowns/spinner ) .
244+
221245``` go
222246display := ishell.ProgressDisplayCharSet (spinner.CharSets [11 ])
223247func (c *Context ) { c.ProgressBar ().Display (display) ... }
@@ -227,13 +251,14 @@ ishell.ProgressBar().Display(display)
227251```
228252
229253### Durable history
254+
230255``` go
231256// Read and write history to $HOME/.ishell_history
232257shell.SetHomeHistoryPath (" .ishell_history" )
233258```
234259
235-
236260### Non-interactive execution
261+
237262In some situations it is desired to exit the program directly after executing a single command.
238263
239264``` go
@@ -256,8 +281,8 @@ $ go run main.go exit greet Someusername
256281Hello Someusername
257282```
258283
259-
260284### Output with Color
285+
261286You can use [ fatih/color] ( https://github.com/fatih/color ) .
262287
263288``` go
@@ -266,56 +291,65 @@ func(c *ishell.Context) {
266291 c.Println (yellow (" This line is yellow" ))
267292}
268293```
294+
269295Execution
296+
270297``` sh
271298>>> color
272299This line is yellow
273300```
274301
275-
276302### Example
303+
277304Available [ here] ( https://github.com/abiosoft/ishell/blob/master/example/main.go ) .
305+
278306``` sh
279307go run example/main.go
280308```
281309
282310## Supported Platforms
283- * [x] Linux
284- * [x] OSX
285- * [x] Windows [ Not tested but should work]
311+
312+ - [x] Linux
313+ - [x] OSX
314+ - [x] Windows [ Not tested but should work]
286315
287316## Note
317+
288318ishell is in active development and can still change significantly.
289319
290320## Roadmap (in no particular order)
291- * [x] Multiline inputs
292- * [x] Command history
293- * [x] Customizable tab completion
294- * [x] Handle ^C interrupts
295- * [x] Subcommands and help texts
296- * [x] Scrollable paged output
297- * [x] Progress bar
298- * [x] Multiple choice prompt
299- * [x] Checklist prompt
300- * [x] Support for command aliases
301- * [ ] Multiple line progress bars
302- * [ ] Testing, testing, testing
321+
322+ - [x] Multiline inputs
323+ - [x] Command history
324+ - [x] Customizable tab completion
325+ - [x] Handle ^C interrupts
326+ - [x] Subcommands and help texts
327+ - [x] Scrollable paged output
328+ - [x] Progress bar
329+ - [x] Multiple choice prompt
330+ - [x] Checklist prompt
331+ - [x] Support for command aliases
332+ - [ ] Multiple line progress bars
333+ - [ ] Testing, testing, testing
303334
304335## Contribution
336+
3053371 . Create an issue to discuss it.
3063382 . Send in Pull Request.
307339
308340## License
341+
309342MIT
310343
311344## Credits
312- Library | Use
313- ------- | -----
314- [ github.com/flynn-archive/go-shlex] ( https://github.com/flynn-archive/go-shlex ) | splitting input into command and args.
315- [ github.com/chzyer/readline] ( https://github.com/chzyer/readline ) | readline capabilities.
316345
346+ | Library | Use |
347+ | ------------------------------------------------------------------------------ | -------------------------------------- |
348+ | [ github.com/flynn-archive/go-shlex] ( https://github.com/flynn-archive/go-shlex ) | splitting input into command and args. |
349+ | [ github.com/chzyer/readline] ( https://github.com/chzyer/readline ) | readline capabilities. |
317350
318351## Donate
352+
319353```
320354bitcoin: 1GTHYEDiy2C7RzXn5nY4wVRaEN2GvLjwZN
321355paypal: a@abiosoft.com
0 commit comments