Merge pull request #1013 from a-dwarf/main

feature: bbgo completion
This commit is contained in:
Yo-An Lin 2022-11-25 14:55:18 +08:00 committed by GitHub
commit 98f70756be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 77 additions and 2 deletions

View File

@ -7,6 +7,7 @@
* [Back-testing](topics/back-testing.md) - How to back-test strategies
* [TWAP](topics/twap.md) - TWAP order execution to buy/sell large quantity of order
* [Dnum Installation](topics/dnum-binary.md) - installation of high-precision version of bbgo
* [bbgo completion](topics/bbgo-completion.md) - Convenient use of the command line
### Configuration
* [Setting up Slack Notification](configuration/slack.md)

View File

@ -0,0 +1,70 @@
# bbgo Completion
## usage
```shell
(base) ➜ bbgo git:(main) ✗ bbgo completion -h
./build/bbgo/bbgo completion -h
Generate the autocompletion script for bbgo for the specified shell.
See each sub-command's help for details on how to use the generated script.
Usage:
bbgo completion [command]
Available Commands:
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
```
## shell configuration
```shell
(base) ➜ bbgo git:(main) ✗ ./build/bbgo/bbgo completion zsh -h
Generate the autocompletion script for the zsh shell.
If shell completion is not already enabled in your environment you will need
to enable it. You can execute the following once:
echo "autoload -U compinit; compinit" >> ~/.zshrc
To load completions in your current shell session:
source <(bbgo completion zsh); compdef _bbgo bbgo
To load completions for every new session, execute once:
#### Linux:
bbgo completion zsh > "${fpath[1]}/_bbgo"
#### macOS:
bbgo completion zsh > $(brew --prefix)/share/zsh/site-functions/_bbgo
You will need to start a new shell for this setup to take effect.
```
## demo effect
Use the `tab` key to bring up the autocomplete prompt4
```shell
(base) ➜ bbgo git:(main) ✗ ./build/bbgo/bbgo account -
--binance-api-key -- binance api key
--binance-api-secret -- binance api secret
--config -- config file
--cpu-profile -- cpu profile
--debug -- debug mode
--dotenv -- the dotenv file you want to load
--ftx-api-key -- ftx api key
--ftx-api-secret -- ftx api secret
--ftx-subaccount -- subaccount name. Specify it if the crede
```

4
go.mod
View File

@ -42,7 +42,7 @@ require (
github.com/sajari/regression v1.0.1
github.com/sirupsen/logrus v1.8.1
github.com/slack-go/slack v0.10.1
github.com/spf13/cobra v1.1.1
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.1
github.com/stretchr/testify v1.7.4
@ -90,7 +90,7 @@ require (
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect

4
go.sum
View File

@ -339,6 +339,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
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.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
@ -631,6 +633,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.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4=
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
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=