diff --git a/README.md b/README.md index 4f394b2..5a28c2b 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ The commands are described below, and any accompanying args/flags will be in the The CLI currently supports the following products: - [api](./docs/api.md) +- [completion](./docs/completion.md) - [configure](./docs/configure.md) - [event](docs/event.md) - [mock-api](docs/mock-api.md) diff --git a/docs/completion.md b/docs/completion.md new file mode 100644 index 0000000..208e1bb --- /dev/null +++ b/docs/completion.md @@ -0,0 +1,99 @@ +# Completion + +Generate autocompletions for your desired shell. + +## Arguments + +| Argument | Description | +| ---------- | ------------------------------------------------- | +| bash | Generate the autocompletion script for bash | +| fish | Generate the autocompletion script for fish | +| powershell | Generate the autocompletion script for powershell | +| zsh | Generate the autocompletion script for zsh | + +## Usage + +### Bash + +This script depends on the 'bash-completion' package. +If it is not installed already, you can install it via your OS's package manager. + +To load completions in your current shell session: + +```bash +source <(twitch completion bash) +``` + +To load completions for every new session, execute once: + +#### Linux: + +```bash +twitch completion bash > /etc/bash_completion.d/twitch +``` + +#### macOS: + +```bash +twitch completion bash > $(brew --prefix)/etc/bash_completion.d/twitch +``` + +You will need to start a new shell for this setup to take effect. + +### Zsh + +If shell completion is not already enabled in your environment you will need +to enable it. You can execute the following once: + +```zsh +echo "autoload -U compinit; compinit" >> ~/.zshrc +``` + +To load completions in your current shell session: + +```zsh +source <(twitch completion zsh) +``` + +To load completions for every new session, execute once: + +#### Linux: + +```zsh +twitch completion zsh > "${fpath[1]}/_twitch" +``` + +#### macOS: + +```zsh +twitch completion zsh > $(brew --prefix)/share/zsh/site-functions/_twitch +``` + +You will need to start a new shell for this setup to take effect. + +### Fish + +To load completions in your current shell session: + +```fish +twitch completion fish | source +``` + +To load completions for every new session, execute once: + +```fish +twitch completion fish > ~/.config/fish/completions/twitch.fish +``` + +You will need to start a new shell for this setup to take effect. + +### PowerShell + +To load completions in your current shell session: + +```powershell +twitch completion powershell | Out-String | Invoke-Expression +``` + +To load completions for every new session, add the output of the above command +to your powershell profile. diff --git a/go.mod b/go.mod index 6830ae0..1eb543f 100755 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/jmoiron/sqlx v1.3.4 github.com/manifoldco/promptui v0.8.0 github.com/mattn/go-sqlite3 v1.14.17 - github.com/spf13/cobra v1.1.3 + github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.8.4 golang.org/x/time v0.0.0-20210611083556-38a9dc6acbc6 @@ -22,7 +22,7 @@ require ( github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hokaccha/go-prettyjson v0.0.0-20201222001619-a42f9ac2ec8e // indirect - github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a // indirect github.com/lunixbochs/vtclean v1.0.0 // indirect github.com/magiconair/properties v1.8.5 // indirect diff --git a/go.sum b/go.sum index f8502a9..6680bfe 100644 --- a/go.sum +++ b/go.sum @@ -39,6 +39,7 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 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 github.com/hokaccha/go-prettyjson v0.0.0-20201222001619-a42f9ac2ec8e/go.mod h1:pFlLw2CfqZiIBOx6BuCeRLCrfxBJipTY0nIOF/VbGcI= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jmoiron/sqlx v1.3.4 h1:wv+0IJZfL5z0uZoUjlpKgHkgaFSYD+r9CfrXjEXsO7w= github.com/jmoiron/sqlx v1.3.4/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ= 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 github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= 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= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=