gctcli: bump urfave cli depends version (#698)

* gctcli: bump version

* gctcli: flag alias done differenttttttttttttt

* gctcli: add autocomplete scripts to folder within gctcli cmd folder structure
This commit is contained in:
Ryan O'Hara-Reid
2021-06-24 15:02:21 +10:00
committed by GitHub
parent d978b3bbdc
commit 79a47cf569
11 changed files with 422 additions and 362 deletions

View File

@@ -1,6 +1,8 @@
#! /bin/bash
# bash programmable completion for gctcli
# copy to /etc/bash_completion.d/gctcli and source it or restart your shell
# For info on implementation for current shell session or persistence:
# https://github.com/urfave/cli/blob/master/docs/v2/manual.md#enabling
: ${PROG:=$(basename ${BASH_SOURCE})}

View File

@@ -0,0 +1,13 @@
# PowerShell programmable completion for gctcli
# For info on implementation for current shell session or persistence:
# https://github.com/urfave/cli/blob/master/docs/v2/manual.md#powershell-support
$fn = $($MyInvocation.MyCommand.Name)
$name = $fn -replace "(.*)\.ps1$", '$1'
Register-ArgumentCompleter -Native -CommandName $name -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
$other = "$wordToComplete --generate-bash-completion"
Invoke-Expression $other | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}

View File

@@ -0,0 +1,27 @@
#compdef $PROG
# zsh programmable completion for gctcli
# For info on implementation for current shell session or persistence:
# https://github.com/urfave/cli/blob/master/docs/v2/manual.md#zsh-support
_gctcli() {
local -a opts
local cur
cur=${words[-1]}
if [[ "$cur" == "-"* ]]; then
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
else
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
fi
if [[ "${opts[1]}" != "" ]]; then
_describe 'values' opts
else
_files
fi
return
}
compdef _gctcli $PROG

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/core"
"github.com/thrasher-corp/gocryptotrader/gctrpc/auth"
"github.com/urfave/cli"
cli "github.com/urfave/cli/v2"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)
@@ -59,38 +59,38 @@ func main() {
app.EnableBashCompletion = true
app.Usage = "command line interface for managing the gocryptotrader daemon"
app.Flags = []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "rpchost",
Value: "localhost:9052",
Usage: "the gRPC host to connect to",
Destination: &host,
},
cli.StringFlag{
&cli.StringFlag{
Name: "rpcuser",
Value: "admin",
Usage: "the gRPC username",
Destination: &username,
},
cli.StringFlag{
&cli.StringFlag{
Name: "rpcpassword",
Value: "Password",
Usage: "the gRPC password",
Destination: &password,
},
cli.StringFlag{
&cli.StringFlag{
Name: "delimiter",
Value: "-",
Usage: "the default currency pair delimiter used to standardise currency pair input",
Destination: &pairDelimiter,
},
cli.StringFlag{
&cli.StringFlag{
Name: "cert",
Value: filepath.Join(common.GetDefaultDataDir(runtime.GOOS), "tls", "cert.pem"),
Usage: "the path to TLS cert of the gRPC server",
Destination: &certPath,
},
}
app.Commands = []cli.Command{
app.Commands = []*cli.Command{
getInfoCommand,
getSubsystemsCommand,
enableSubsystemCommand,

View File

@@ -6,24 +6,24 @@ import (
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/gctrpc"
"github.com/urfave/cli"
cli "github.com/urfave/cli/v2"
)
var exchangePairManagerCommand = cli.Command{
var exchangePairManagerCommand = &cli.Command{
Name: "pair",
Usage: "execute exchange pair management command",
ArgsUsage: "<command> <args>",
Subcommands: []cli.Command{
Subcommands: []*cli.Command{
{
Name: "get",
Usage: "returns all enabled and available pairs by asset type",
ArgsUsage: "<asset>",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
cli.StringFlag{
&cli.StringFlag{
Name: "asset",
Usage: "asset",
},
@@ -34,11 +34,11 @@ var exchangePairManagerCommand = cli.Command{
Name: "disableasset",
Usage: "disables asset type",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
cli.StringFlag{
&cli.StringFlag{
Name: "asset",
Usage: "asset",
},
@@ -49,15 +49,15 @@ var exchangePairManagerCommand = cli.Command{
Name: "enableasset",
Usage: "enables asset type",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
cli.StringFlag{
&cli.StringFlag{
Name: "asset",
Usage: "asset",
},
cli.BoolTFlag{
&cli.BoolFlag{
Name: "enable",
Hidden: true,
},
@@ -68,15 +68,15 @@ var exchangePairManagerCommand = cli.Command{
Name: "disable",
Usage: "disable pairs by asset type",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
cli.StringFlag{
&cli.StringFlag{
Name: "pairs",
Usage: "either a single currency pair string or comma delimiter string of pairs e.g. \"BTC-USD,XRP-USD\"",
},
cli.StringFlag{
&cli.StringFlag{
Name: "asset",
Usage: "asset",
},
@@ -87,19 +87,19 @@ var exchangePairManagerCommand = cli.Command{
Name: "enable",
Usage: "enable pairs by asset type",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
cli.StringFlag{
&cli.StringFlag{
Name: "pairs",
Usage: "either a single currency pair string or comma delimiter string of pairs e.g. \"BTC-USD,XRP-USD\"",
},
cli.StringFlag{
&cli.StringFlag{
Name: "asset",
Usage: "asset",
},
cli.BoolTFlag{
&cli.BoolFlag{
Name: "enable",
Hidden: true,
},
@@ -110,11 +110,11 @@ var exchangePairManagerCommand = cli.Command{
Name: "enableall",
Usage: "enable all pairs",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
cli.BoolTFlag{
&cli.BoolFlag{
Name: "enable",
Hidden: true,
},
@@ -125,7 +125,7 @@ var exchangePairManagerCommand = cli.Command{
Name: "disableall",
Usage: "dissable all pairs",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
@@ -136,7 +136,7 @@ var exchangePairManagerCommand = cli.Command{
Name: "update",
Usage: "fetches supported pairs from the exchange and updates available pairs and removes unsupported enable pairs",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
@@ -147,7 +147,7 @@ var exchangePairManagerCommand = cli.Command{
Name: "getassets",
Usage: "fetches supported assets",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
@@ -158,7 +158,7 @@ var exchangePairManagerCommand = cli.Command{
}
func enableDisableExchangePair(c *cli.Context) error {
enable := c.BoolT("enable")
enable := c.Bool("enable")
if c.NArg() == 0 && c.NumFlags() == 0 {
if enable {
return cli.ShowCommandHelp(c, "enable")
@@ -292,7 +292,7 @@ func getExchangePairs(c *cli.Context) error {
}
func enableDisableExchangeAsset(c *cli.Context) error {
enable := c.BoolT("enable")
enable := c.Bool("enable")
if c.NArg() == 0 && c.NumFlags() == 0 {
if enable {
return cli.ShowCommandHelp(c, "enableasset")
@@ -346,7 +346,7 @@ func enableDisableExchangeAsset(c *cli.Context) error {
}
func enableDisableAllExchangePairs(c *cli.Context) error {
enable := c.BoolT("enable")
enable := c.Bool("enable")
if c.NArg() == 0 && c.NumFlags() == 0 {
if enable {
return cli.ShowCommandHelp(c, "enableall")

View File

@@ -10,25 +10,26 @@ import (
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/gctrpc"
"github.com/urfave/cli"
cli "github.com/urfave/cli/v2"
)
var tradeCommand = cli.Command{
var tradeCommand = &cli.Command{
Name: "trade",
Usage: "execute trade related commands",
ArgsUsage: "<command> <args>",
Subcommands: []cli.Command{
Subcommands: []*cli.Command{
{
Name: "setexchangetradeprocessing",
Usage: "sets whether an exchange can save trades to the database",
ArgsUsage: "<exchange> <status>",
Action: setExchangeTradeProcessing,
Flags: []cli.Flag{
cli.StringFlag{
Name: "exchange, e",
Usage: "the exchange to change the status of",
&cli.StringFlag{
Name: "exchange",
Aliases: []string{"e"},
Usage: "the exchange to change the status of",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "status",
Usage: "<true>/<false>",
},
@@ -40,17 +41,20 @@ var tradeCommand = cli.Command{
ArgsUsage: "<exchange> <pair> <asset>",
Action: getRecentTrades,
Flags: []cli.Flag{
cli.StringFlag{
Name: "exchange, e",
Usage: "the exchange to get the trades from",
&cli.StringFlag{
Name: "exchange",
Aliases: []string{"e"},
Usage: "the exchange to get the trades from",
},
cli.StringFlag{
Name: "pair, p",
Usage: "the currency pair to get the trades for",
&cli.StringFlag{
Name: "pair",
Aliases: []string{"p"},
Usage: "the currency pair to get the trades for",
},
cli.StringFlag{
Name: "asset, a",
Usage: "the asset type of the currency pair",
&cli.StringFlag{
Name: "asset",
Aliases: []string{"a"},
Usage: "the asset type of the currency pair",
},
},
},
@@ -60,25 +64,28 @@ var tradeCommand = cli.Command{
ArgsUsage: "<exchange> <pair> <asset> <start> <end>",
Action: getHistoricTrades,
Flags: []cli.Flag{
cli.StringFlag{
Name: "exchange, e",
Usage: "the exchange to get the trades from",
&cli.StringFlag{
Name: "exchange",
Aliases: []string{"e"},
Usage: "the exchange to get the trades from",
},
cli.StringFlag{
Name: "pair, p",
Usage: "the currency pair to get the trades for",
&cli.StringFlag{
Name: "pair",
Aliases: []string{"p"},
Usage: "the currency pair to get the trades for",
},
cli.StringFlag{
Name: "asset, a",
Usage: "the asset type of the currency pair",
&cli.StringFlag{
Name: "asset",
Aliases: []string{"a"},
Usage: "the asset type of the currency pair",
},
cli.StringFlag{
&cli.StringFlag{
Name: "start",
Usage: "<start>",
Value: time.Now().Add(-time.Hour * 6).Format(common.SimpleTimeFormat),
Destination: &startTime,
},
cli.StringFlag{
&cli.StringFlag{
Name: "end",
Usage: "<end> WARNING: large date ranges may take considerable time",
Value: time.Now().Format(common.SimpleTimeFormat),
@@ -92,25 +99,28 @@ var tradeCommand = cli.Command{
ArgsUsage: "<exchange> <pair> <asset> <start> <end>",
Action: getSavedTrades,
Flags: []cli.Flag{
cli.StringFlag{
Name: "exchange, e",
Usage: "the exchange to get the trades from",
&cli.StringFlag{
Name: "exchange",
Aliases: []string{"e"},
Usage: "the exchange to get the trades from",
},
cli.StringFlag{
Name: "pair, p",
Usage: "the currency pair to get the trades for",
&cli.StringFlag{
Name: "pair",
Aliases: []string{"p"},
Usage: "the currency pair to get the trades for",
},
cli.StringFlag{
Name: "asset, a",
Usage: "the asset type of the currency pair",
&cli.StringFlag{
Name: "asset",
Aliases: []string{"a"},
Usage: "the asset type of the currency pair",
},
cli.StringFlag{
&cli.StringFlag{
Name: "start",
Usage: "<start>",
Value: time.Now().AddDate(0, -1, 0).Format(common.SimpleTimeFormat),
Destination: &startTime,
},
cli.StringFlag{
&cli.StringFlag{
Name: "end",
Usage: "<end>",
Value: time.Now().Format(common.SimpleTimeFormat),
@@ -124,25 +134,28 @@ var tradeCommand = cli.Command{
ArgsUsage: "<exchange> <pair> <asset> <start> <end>",
Action: findMissingSavedTradeIntervals,
Flags: []cli.Flag{
cli.StringFlag{
Name: "exchange, e",
Usage: "the exchange to find the missing trades",
&cli.StringFlag{
Name: "exchange",
Aliases: []string{"e"},
Usage: "the exchange to find the missing trades",
},
cli.StringFlag{
Name: "pair, p",
Usage: "the currency pair",
&cli.StringFlag{
Name: "pair",
Aliases: []string{"p"},
Usage: "the currency pair",
},
cli.StringFlag{
Name: "asset, a",
Usage: "the asset type of the currency pair",
&cli.StringFlag{
Name: "asset",
Aliases: []string{"a"},
Usage: "the asset type of the currency pair",
},
cli.StringFlag{
&cli.StringFlag{
Name: "start",
Usage: "<start> rounded down to the nearest hour",
Value: time.Now().Add(-time.Hour * 24).Truncate(time.Hour).Format(common.SimpleTimeFormat),
Destination: &startTime,
},
cli.StringFlag{
&cli.StringFlag{
Name: "end",
Usage: "<end> rounded down to the nearest hour",
Value: time.Now().Truncate(time.Hour).Format(common.SimpleTimeFormat),
@@ -156,43 +169,49 @@ var tradeCommand = cli.Command{
ArgsUsage: "<exchange> <pair> <asset> <interval> <start> <end>",
Action: convertSavedTradesToCandles,
Flags: []cli.Flag{
cli.StringFlag{
Name: "exchange, e",
Usage: "the exchange",
&cli.StringFlag{
Name: "exchange",
Aliases: []string{"e"},
Usage: "the exchange",
},
cli.StringFlag{
Name: "pair, p",
Usage: "the currency pair to get the trades for",
&cli.StringFlag{
Name: "pair",
Aliases: []string{"p"},
Usage: "the currency pair to get the trades for",
},
cli.StringFlag{
Name: "asset, a",
Usage: "the asset type of the currency pair",
&cli.StringFlag{
Name: "asset",
Aliases: []string{"a"},
Usage: "the asset type of the currency pair",
},
cli.Int64Flag{
Name: "interval, i",
&cli.Int64Flag{
Name: "interval",
Aliases: []string{"i"},
Usage: fmt.Sprintf(klineMessage, "interval"),
Value: 86400,
Destination: &candleGranularity,
},
cli.StringFlag{
&cli.StringFlag{
Name: "start",
Usage: "<start>",
Value: time.Now().AddDate(0, -1, 0).Format(common.SimpleTimeFormat),
Destination: &startTime,
},
cli.StringFlag{
&cli.StringFlag{
Name: "end",
Usage: "<end>",
Value: time.Now().Format(common.SimpleTimeFormat),
Destination: &endTime,
},
cli.BoolFlag{
Name: "sync, s",
Usage: "will sync the resulting candles to the database <true/false>",
&cli.BoolFlag{
Name: "sync",
Aliases: []string{"s"},
Usage: "will sync the resulting candles to the database <true/false>",
},
cli.BoolFlag{
Name: "force, f",
Usage: "will overwrite any conflicting candle data on save <true/false>",
&cli.BoolFlag{
Name: "force",
Aliases: []string{"f"},
Usage: "will overwrite any conflicting candle data on save <true/false>",
},
},
},

View File

@@ -5,19 +5,19 @@ import (
"fmt"
"github.com/thrasher-corp/gocryptotrader/gctrpc"
"github.com/urfave/cli"
cli "github.com/urfave/cli/v2"
)
var websocketManagerCommand = cli.Command{
var websocketManagerCommand = &cli.Command{
Name: "websocket",
Usage: "execute websocket management command",
ArgsUsage: "<command> <args>",
Subcommands: []cli.Command{
Subcommands: []*cli.Command{
{
Name: "getinfo",
Usage: "returns all exchange websocket information",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
@@ -28,7 +28,7 @@ var websocketManagerCommand = cli.Command{
Name: "disable",
Usage: "disables websocket connection for an exchange",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
@@ -39,11 +39,11 @@ var websocketManagerCommand = cli.Command{
Name: "enable",
Usage: "enables websocket connection for an exchange",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
cli.BoolTFlag{
&cli.BoolFlag{
Name: "enable",
Hidden: true,
},
@@ -54,7 +54,7 @@ var websocketManagerCommand = cli.Command{
Name: "getsubs",
Usage: "returns current subscriptions for an exchange",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
@@ -65,11 +65,11 @@ var websocketManagerCommand = cli.Command{
Name: "setproxy",
Usage: "sets exchange websocket proxy, flushes and reroutes connection",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
cli.StringFlag{
&cli.StringFlag{
Name: "proxy",
Usage: "proxy address to change to, if proxy string is not set, this will stop the utilization of the prior set proxy.",
},
@@ -80,11 +80,11 @@ var websocketManagerCommand = cli.Command{
Name: "seturl",
Usage: "sets exchange websocket endpoint URL and resets the websocket connection",
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "exchange",
Usage: "the exchange to act on",
},
cli.StringFlag{
&cli.StringFlag{
Name: "url",
Usage: "url string to change to, an empty string will set it back to the packaged defined default",
},
@@ -127,7 +127,7 @@ func getwebsocketInfo(c *cli.Context) error {
}
func enableDisableWebsocket(c *cli.Context) error {
enable := c.BoolT("enable")
enable := c.Bool("enable")
if c.NArg() == 0 && c.NumFlags() == 0 {
return cli.ShowSubcommandHelp(c)
}

View File

@@ -1,14 +0,0 @@
# zsh programmable completion for gctcli
# source zsh_autocomplete
_gctcli() {
local -a opts
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
_describe 'values' opts
return
}
compdef _gctcli gctcli

1
go.mod
View File

@@ -26,7 +26,6 @@ require (
github.com/thrasher-corp/goose v2.7.0-rc4.0.20191002032028-0f2c2a27abdb+incompatible
github.com/thrasher-corp/sqlboiler v1.0.1-0.20191001234224-71e17f37a85e
github.com/toorop/go-pusher v0.0.0-20180521062818-4521e2eb39fb
github.com/urfave/cli v1.22.5
github.com/urfave/cli/v2 v2.3.0
github.com/volatiletech/inflect v0.0.1 // indirect
github.com/volatiletech/null v8.0.0+incompatible

2
go.sum
View File

@@ -371,8 +371,6 @@ github.com/toorop/go-pusher v0.0.0-20180521062818-4521e2eb39fb h1:9kcmLvQdiIecpg
github.com/toorop/go-pusher v0.0.0-20180521062818-4521e2eb39fb/go.mod h1:VTLqNCX1tXrur6pdIRCl8Q90FR7nw/mEBdyMkWMcsb0=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/volatiletech/inflect v0.0.0-20170731032912-e7201282ae8d/go.mod h1:jspfvgf53t5NLUT4o9L1IX0kIBNKamGq1tWc/MgWK9Q=