Skip to content

Commit a367bec

Browse files
authored
Merge pull request #339 from hougesen/feat/shell-completion
Add shell completion command by bumping cobra to 1.8.1
2 parents a14bb8b + 271e0bb commit a367bec

4 files changed

Lines changed: 108 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ The commands are described below, and any accompanying args/flags will be in the
124124
The CLI currently supports the following products:
125125

126126
- [api](./docs/api.md)
127+
- [completion](./docs/completion.md)
127128
- [configure](./docs/configure.md)
128129
- [event](docs/event.md)
129130
- [mock-api](docs/mock-api.md)

docs/completion.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Completion
2+
3+
Generate autocompletions for your desired shell.
4+
5+
## Arguments
6+
7+
| Argument | Description |
8+
| ---------- | ------------------------------------------------- |
9+
| bash | Generate the autocompletion script for bash |
10+
| fish | Generate the autocompletion script for fish |
11+
| powershell | Generate the autocompletion script for powershell |
12+
| zsh | Generate the autocompletion script for zsh |
13+
14+
## Usage
15+
16+
### Bash
17+
18+
This script depends on the 'bash-completion' package.
19+
If it is not installed already, you can install it via your OS's package manager.
20+
21+
To load completions in your current shell session:
22+
23+
```bash
24+
source <(twitch completion bash)
25+
```
26+
27+
To load completions for every new session, execute once:
28+
29+
#### Linux:
30+
31+
```bash
32+
twitch completion bash > /etc/bash_completion.d/twitch
33+
```
34+
35+
#### macOS:
36+
37+
```bash
38+
twitch completion bash > $(brew --prefix)/etc/bash_completion.d/twitch
39+
```
40+
41+
You will need to start a new shell for this setup to take effect.
42+
43+
### Zsh
44+
45+
If shell completion is not already enabled in your environment you will need
46+
to enable it. You can execute the following once:
47+
48+
```zsh
49+
echo "autoload -U compinit; compinit" >> ~/.zshrc
50+
```
51+
52+
To load completions in your current shell session:
53+
54+
```zsh
55+
source <(twitch completion zsh)
56+
```
57+
58+
To load completions for every new session, execute once:
59+
60+
#### Linux:
61+
62+
```zsh
63+
twitch completion zsh > "${fpath[1]}/_twitch"
64+
```
65+
66+
#### macOS:
67+
68+
```zsh
69+
twitch completion zsh > $(brew --prefix)/share/zsh/site-functions/_twitch
70+
```
71+
72+
You will need to start a new shell for this setup to take effect.
73+
74+
### Fish
75+
76+
To load completions in your current shell session:
77+
78+
```fish
79+
twitch completion fish | source
80+
```
81+
82+
To load completions for every new session, execute once:
83+
84+
```fish
85+
twitch completion fish > ~/.config/fish/completions/twitch.fish
86+
```
87+
88+
You will need to start a new shell for this setup to take effect.
89+
90+
### PowerShell
91+
92+
To load completions in your current shell session:
93+
94+
```powershell
95+
twitch completion powershell | Out-String | Invoke-Expression
96+
```
97+
98+
To load completions for every new session, add the output of the above command
99+
to your powershell profile.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/jmoiron/sqlx v1.3.4
1010
github.com/manifoldco/promptui v0.8.0
1111
github.com/mattn/go-sqlite3 v1.14.17
12-
github.com/spf13/cobra v1.1.3
12+
github.com/spf13/cobra v1.8.1
1313
github.com/spf13/viper v1.7.1
1414
github.com/stretchr/testify v1.8.4
1515
golang.org/x/time v0.0.0-20210611083556-38a9dc6acbc6
@@ -22,7 +22,7 @@ require (
2222
github.com/hashicorp/go-version v1.6.0 // indirect
2323
github.com/hashicorp/hcl v1.0.0 // indirect
2424
github.com/hokaccha/go-prettyjson v0.0.0-20201222001619-a42f9ac2ec8e // indirect
25-
github.com/inconshreveable/mousetrap v1.0.0 // indirect
25+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
2626
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect
2727
github.com/lunixbochs/vtclean v1.0.0 // indirect
2828
github.com/magiconair/properties v1.8.5 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
3939
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
4040
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
4141
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
42+
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
4243
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4344
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
4445
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -113,6 +114,8 @@ github.com/hokaccha/go-prettyjson v0.0.0-20201222001619-a42f9ac2ec8e h1:1vxUQ6PL
113114
github.com/hokaccha/go-prettyjson v0.0.0-20201222001619-a42f9ac2ec8e/go.mod h1:pFlLw2CfqZiIBOx6BuCeRLCrfxBJipTY0nIOF/VbGcI=
114115
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
115116
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
117+
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
118+
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
116119
github.com/jmoiron/sqlx v1.3.4 h1:wv+0IJZfL5z0uZoUjlpKgHkgaFSYD+r9CfrXjEXsO7w=
117120
github.com/jmoiron/sqlx v1.3.4/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ=
118121
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
@@ -192,6 +195,7 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T
192195
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
193196
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
194197
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
198+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
195199
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
196200
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
197201
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
@@ -210,6 +214,8 @@ github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
210214
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
211215
github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M=
212216
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
217+
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
218+
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
213219
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
214220
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
215221
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=

0 commit comments

Comments
 (0)