Skip to content

Commit 1c52a1a

Browse files
committed
add go module
1 parent 1b6ad7e commit 1c52a1a

File tree

4 files changed

+106
-32
lines changed

4 files changed

+106
-32
lines changed

README.md

+63-29
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
# ishell
2+
23
ishell 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+
4136
Execution
37+
4238
```
4339
Sample Interactive Shell
4440
>>> help
@@ -56,6 +52,7 @@ $
5652
```
5753

5854
### Reading input
55+
5956
```go
6057
// simulate an authentication
6158
shell.AddCmd(&ishell.Cmd{
@@ -80,7 +77,9 @@ shell.AddCmd(&ishell.Cmd{
8077
},
8178
})
8279
```
80+
8381
Execution
82+
8483
```
8584
>>> login
8685
Username: someusername
@@ -89,7 +88,9 @@ Authentication Successful.
8988
```
9089

9190
### Multiline input
91+
9292
Builtin 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+
102104
User defined
105+
103106
```go
104107
shell.AddCmd(&ishell.Cmd{
105108
Name: "multi",
@@ -112,7 +115,9 @@ shell.AddCmd(&ishell.Cmd{
112115
},
113116
})
114117
```
118+
115119
Execution
120+
116121
```
117122
>>> multi
118123
Input multiple lines and end with semicolon ';'.
@@ -122,16 +127,21 @@ You wrote:
122127
this is user defined
123128
multiline input;
124129
```
130+
125131
### Keyboard interrupt
132+
126133
Builtin interrupt handler.
134+
127135
```
128136
>>> ^C
129137
Input Ctrl-C once more to exit
130138
>>> ^C
131139
Interrupted
132140
exit status 1
133141
```
142+
134143
Custom
144+
135145
```go
136146
shell.Interrupt(func(count int, c *ishell.Context) { ... })
137147
```
@@ -153,7 +163,9 @@ func(c *ishell.Context) {
153163
}
154164
},
155165
```
166+
156167
Output
168+
157169
```
158170
What are Go programmers called ?
159171
Golangers
@@ -163,7 +175,9 @@ What are Go programmers called ?
163175
164176
You got it!
165177
```
178+
166179
### Checklist
180+
167181
```go
168182
func(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+
176191
Output
192+
177193
```
178194
What are your favourite programming languages ?
179195
Python
@@ -185,7 +201,9 @@ Your choices are Go, Rust
185201
```
186202

187203
### Progress Bar
204+
188205
Determinate
206+
189207
```go
190208
func(c *ishell.Context) {
191209
c.ProgressBar().Start()
@@ -197,12 +215,15 @@ func(c *ishell.Context) {
197215
c.ProgressBar().Stop()
198216
}
199217
```
218+
200219
Output
220+
201221
```
202222
[==========> ] 50%
203223
```
204224

205225
Indeterminate
226+
206227
```go
207228

208229
func(c *ishell.Context) {
@@ -212,12 +233,15 @@ func(c *ishell.Context) {
212233
c.ProgressBar().Stop()
213234
}
214235
```
236+
215237
Output
238+
216239
```
217240
[ ==== ]
218241
```
219242

220243
Custom display using [briandowns/spinner](https://github.com/briandowns/spinner).
244+
221245
```go
222246
display := ishell.ProgressDisplayCharSet(spinner.CharSets[11])
223247
func(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
232257
shell.SetHomeHistoryPath(".ishell_history")
233258
```
234259

235-
236260
### Non-interactive execution
261+
237262
In 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
256281
Hello Someusername
257282
```
258283

259-
260284
### Output with Color
285+
261286
You 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+
269295
Execution
296+
270297
```sh
271298
>>> color
272299
This line is yellow
273300
```
274301

275-
276302
### Example
303+
277304
Available [here](https://github.com/abiosoft/ishell/blob/master/example/main.go).
305+
278306
```sh
279307
go 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+
288318
ishell 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+
305337
1. Create an issue to discuss it.
306338
2. Send in Pull Request.
307339

308340
## License
341+
309342
MIT
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
```
320354
bitcoin: 1GTHYEDiy2C7RzXn5nY4wVRaEN2GvLjwZN
321355

example/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ func main() {
1717
// display info.
1818
shell.Println("Sample Interactive Shell")
1919

20-
//Consider the unicode characters supported by the users font
21-
//shell.SetMultiChoicePrompt(" >>"," - ")
22-
//shell.SetChecklistOptions("[ ] ","[X] ")
20+
// Consider the unicode characters supported by the users font
21+
// shell.SetMultiChoicePrompt(" >>"," - ")
22+
// shell.SetChecklistOptions("[ ] ","[X] ")
2323

2424
// handle login.
2525
shell.AddCmd(&ishell.Cmd{

go.mod

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module github.com/abiosoft/ishell
2+
3+
go 1.16
4+
5+
require (
6+
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db
7+
github.com/chzyer/logex v1.1.10 // indirect
8+
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
9+
github.com/fatih/color v1.12.0
10+
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568
11+
github.com/stretchr/testify v1.7.0
12+
)

go.sum

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db h1:CjPUSXOiYptLbTdr1RceuZgSFDQ7U15ITERUGrUORx8=
2+
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db/go.mod h1:rB3B4rKii8V21ydCbIzH5hZiCQE7f5E9SzUb/ZZx530=
3+
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
4+
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
5+
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
6+
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
7+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
8+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9+
github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc=
10+
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
11+
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BMXYYRWTLOJKlh+lOBt6nUQgXAfB7oVIQt5cNreqSLI=
12+
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:rZfgFAXFS/z/lEd6LJmf9HVZ1LkgYiHx5pHhV5DR16M=
13+
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
14+
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
15+
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
16+
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
17+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
18+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
19+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
20+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
21+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
22+
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
23+
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
24+
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
25+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
26+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
27+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
28+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)