From 6db934853d80cf91e656bdf67b62a49e9e68d3d1 Mon Sep 17 00:00:00 2001 From: Igor Postelnik Date: Tue, 23 Feb 2021 13:48:32 -0600 Subject: [PATCH] TUN-3963: Repoint urfave/cli/v2 library at patched branch at github.com/ipostelnik/cli/v2@fixed which correctly handles reading flags declared at multiple levels of subcommands. --- CHANGES.md | 60 ++++++--- go.mod | 2 + go.sum | 11 ++ vendor/github.com/rs/zerolog/go.mod | 2 - vendor/github.com/urfave/cli/v2/README.md | 12 +- .../cli/v2/altsrc/default_input_source.go | 6 + vendor/github.com/urfave/cli/v2/altsrc/fg.py | 45 +++++++ .../github.com/urfave/cli/v2/altsrc/flag.go | 34 ++--- .../urfave/cli/v2/altsrc/flag_generated.go | 124 +++--------------- .../cli/v2/altsrc/json_source_context.go | 6 +- .../urfave/cli/v2/altsrc/map_input_source.go | 5 + .../urfave/cli/v2/altsrc/toml_file_loader.go | 8 +- .../urfave/cli/v2/altsrc/yaml_file_loader.go | 8 +- vendor/github.com/urfave/cli/v2/app.go | 40 +++--- vendor/github.com/urfave/cli/v2/command.go | 4 +- vendor/github.com/urfave/cli/v2/context.go | 82 +++++++++--- vendor/github.com/urfave/cli/v2/docs.go | 19 ++- vendor/github.com/urfave/cli/v2/errors.go | 28 ++-- vendor/github.com/urfave/cli/v2/fish.go | 4 + vendor/github.com/urfave/cli/v2/flag.go | 6 +- vendor/github.com/urfave/cli/v2/flag_bool.go | 8 +- .../github.com/urfave/cli/v2/flag_duration.go | 8 +- .../github.com/urfave/cli/v2/flag_float64.go | 8 +- .../urfave/cli/v2/flag_float64_slice.go | 8 +- .../github.com/urfave/cli/v2/flag_generic.go | 10 +- vendor/github.com/urfave/cli/v2/flag_int.go | 8 +- vendor/github.com/urfave/cli/v2/flag_int64.go | 8 +- .../urfave/cli/v2/flag_int64_slice.go | 5 +- .../urfave/cli/v2/flag_int_slice.go | 8 +- vendor/github.com/urfave/cli/v2/flag_path.go | 9 +- .../github.com/urfave/cli/v2/flag_string.go | 8 +- .../urfave/cli/v2/flag_string_slice.go | 19 ++- .../urfave/cli/v2/flag_timestamp.go | 12 +- vendor/github.com/urfave/cli/v2/flag_uint.go | 8 +- .../github.com/urfave/cli/v2/flag_uint64.go | 8 +- vendor/github.com/urfave/cli/v2/go.mod | 2 +- vendor/github.com/urfave/cli/v2/go.sum | 4 +- vendor/github.com/urfave/cli/v2/help.go | 30 ++++- vendor/github.com/urfave/cli/v2/template.go | 8 +- vendor/modules.txt | 3 +- 40 files changed, 380 insertions(+), 308 deletions(-) create mode 100644 vendor/github.com/urfave/cli/v2/altsrc/default_input_source.go create mode 100644 vendor/github.com/urfave/cli/v2/altsrc/fg.py diff --git a/CHANGES.md b/CHANGES.md index 2a5cbe41..e1496b6c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,29 +1,59 @@ **Experimental**: This is a new format for release notes. The format and availability is subject to change. +## UNRELEASED + +### Backward Incompatible Changes + +- none + +### New Features + +- none + +### Improvements + +- Nested commands, such as `cloudflared tunnel run`, now consider CLI arguments even if they appear earlier on the + command. For instance, `cloudflared --config config.yaml tunnel run` will now behave the same as + `cloudflared tunnel --config config.yaml run` + +### Bug Fixes + +- none + ## 2021.2.5 ### New Features -- We introduce [Cloudflare One Routing](https://developers.cloudflare.com/cloudflare-one/tutorials/warp-to-tunnel) in beta mode, where users can create private networks with RFC 1918 IP addresses on Cloudflare's network. Clients running Cloudflare WARP client in the same organization can then connect to services made available by Argo Tunnel. Please share your feedback in the GitHub issue opened. +- We introduce [Cloudflare One Routing](https://developers.cloudflare.com/cloudflare-one/tutorials/warp-to-tunnel) in + beta mode. Cloudflare customer can now connect users and private networks with RFC 1918 IP addresses via the + Cloudflare edge network. Users running Cloudflare WARP client in the same organization can connect to the services + made available by Argo Tunnel IP routes. Please share your feedback in the GitHub issue tracker. ## 2021.2.4 ### Bug Fixes -- Reverts the Improvement released in 2021.2.3 for CLI arguments as it introduced a regression where cloudflared failed to read URLs in configuration files. -- Cloudflared now logs the reason for failed connections if the error is recoverable. +- Reverts the Improvement released in 2021.2.3 for CLI arguments as it introduced a regression where cloudflared failed + to read URLs in configuration files. +- cloudflared now logs the reason for failed connections if the error is recoverable. ## 2021.2.3 - -### Backward Incompatible Changes -- Removes db-connect. The Cloudflare Workers product will continue to support db-connect implementations with versions of cloudflared that predate this release and include support for db-connect. - -### New Features -- Introduces support for proxy configurations with websockets in arbitrary TCP connections (#318). - -### Improvements -- Nested command line arguments (such as `cloudflared tunnel run`) now consider CLI arguments even if they appear earlier in the command. E.g. `cloudflared --config config.yaml tunnel run` will now behave similarly to `cloudflared tunnel --config config.yaml run` - -### Bug Fixes -- The maximum number of upstream connections is now limited by default which should fix reported issues of cloudflared exhausting CPU usage when faced with connectivity issues. + +### Backward Incompatible Changes + +- Removes db-connect. The Cloudflare Workers product will continue to support db-connect implementations with versions + of cloudflared that predate this release and include support for db-connect. + +### New Features + +- Introduces support for proxy configurations with websockets in arbitrary TCP connections (#318). + +### Improvements + +- (reverted) Nested command line argument handling. + +### Bug Fixes + +- The maximum number of upstream connections is now limited by default which should fix reported issues of cloudflared + exhausting CPU usage when faced with connectivity issues. diff --git a/go.mod b/go.mod index ef8d7c33..b03d50f3 100644 --- a/go.mod +++ b/go.mod @@ -57,3 +57,5 @@ require ( gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect zombiezen.com/go/capnproto2 v2.18.0+incompatible ) + +replace github.com/urfave/cli/v2 => github.com/ipostelnik/cli/v2 v2.3.1-0.20210223162147-c8b4f97735e4 diff --git a/go.sum b/go.sum index 99e270f7..fee0d0c9 100644 --- a/go.sum +++ b/go.sum @@ -144,6 +144,8 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/cpu/goacmedns v0.0.1/go.mod h1:sesf/pNnCYwUevQEQfEwY0Y3DydlQWSGZbaMElOWxok= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -350,6 +352,10 @@ github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/infobloxopen/go-trees v0.0.0-20190313150506-2af4e13f9062/go.mod h1:PcNJqIlcX/dj3DTG/+QQnRvSgTMG6CLpRMjWcv4+J6w= +github.com/ipostelnik/cli/v2 v2.3.1-0.20210212191405-2b6ed1f5ef69 h1:TuZfNu8oRuQr6Y8UIvQlpXq+G+SzytMUGx8NrBt+2jg= +github.com/ipostelnik/cli/v2 v2.3.1-0.20210212191405-2b6ed1f5ef69/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= +github.com/ipostelnik/cli/v2 v2.3.1-0.20210223162147-c8b4f97735e4 h1:U2OxGKZHC5puhKZnGo6wWWjuWusJCM6J/S1eF7Vt+Uk= +github.com/ipostelnik/cli/v2 v2.3.1-0.20210223162147-c8b4f97735e4/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/jimstudt/http-authentication v0.0.0-20140401203705-3eca13d6893a/go.mod h1:wK6yTYYcgjHE1Z1QtXACPDjcFJyBskHEdagmnq3vsP8= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc= @@ -549,6 +555,8 @@ github.com/russross/blackfriday v0.0.0-20170610170232-067529f716f4 h1:S9YlS71UNJ github.com/russross/blackfriday v0.0.0-20170610170232-067529f716f4/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +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/sacloud/libsacloud v1.26.1/go.mod h1:79ZwATmHLIFZIMd7sxA3LwzVy/B77uj3LDoToVTxDoQ= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= @@ -590,6 +598,8 @@ github.com/uber-go/atomic v1.3.2/go.mod h1:/Ct5t2lcmbJ4OSe/waGBoaVvVqtO0bmtfVNex github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +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.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4= github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= github.com/vultr/govultr v0.1.4/go.mod h1:9H008Uxr/C4vFNGLqKx232C206GL0PBHzOP0809bGNA= @@ -978,6 +988,7 @@ gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRN gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/rs/zerolog/go.mod b/vendor/github.com/rs/zerolog/go.mod index acba1950..340ed40e 100644 --- a/vendor/github.com/rs/zerolog/go.mod +++ b/vendor/github.com/rs/zerolog/go.mod @@ -1,7 +1,5 @@ module github.com/rs/zerolog -go 1.15 - require ( github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e github.com/pkg/errors v0.8.1 diff --git a/vendor/github.com/urfave/cli/v2/README.md b/vendor/github.com/urfave/cli/v2/README.md index c9237fbc..2b74f1f2 100644 --- a/vendor/github.com/urfave/cli/v2/README.md +++ b/vendor/github.com/urfave/cli/v2/README.md @@ -1,7 +1,7 @@ cli === -[![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://godoc.org/github.com/urfave/cli) +[![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://pkg.go.dev/github.com/urfave/cli/v2) [![codebeat](https://codebeat.co/badges/0a8f30aa-f975-404b-b878-5fab3ae1cc5f)](https://codebeat.co/projects/github-com-urfave-cli) [![Go Report Card](https://goreportcard.com/badge/urfave/cli)](https://goreportcard.com/report/urfave/cli) [![codecov](https://codecov.io/gh/urfave/cli/branch/master/graph/badge.svg)](https://codecov.io/gh/urfave/cli) @@ -17,11 +17,15 @@ Usage documentation exists for each major version. Don't know what version you'r - `v2` - [./docs/v2/manual.md](./docs/v2/manual.md) - `v1` - [./docs/v1/manual.md](./docs/v1/manual.md) +Guides for migrating to newer versions: + +- `v1-to-v2` - [./docs/migrate-v1-to-v2.md](./docs/migrate-v1-to-v2.md) + ## Installation -Make sure you have a working Go environment. Go version 1.11+ is supported. [See the install instructions for Go](http://golang.org/doc/install.html). +Using this package requires a working Go environment. [See the install instructions for Go](http://golang.org/doc/install.html). -Go Modules are strongly recommended when using this package. [See the go blog guide on using Go Modules](https://blog.golang.org/using-go-modules). +Go Modules are required when using this package. [See the go blog guide on using Go Modules](https://blog.golang.org/using-go-modules). ### Using `v2` releases @@ -63,4 +67,4 @@ export PATH=$PATH:$GOPATH/bin cli is tested against multiple versions of Go on Linux, and against the latest released version of Go on OS X and Windows. This project uses Github Actions for -builds. For more build info, please look at the [./.github/workflows/cli.yml](https://github.com/urfave/cli/blob/master/.github/workflows/cli.yml). +builds. To see our currently supported go versions and platforms, look at the [./.github/workflows/cli.yml](https://github.com/urfave/cli/blob/master/.github/workflows/cli.yml). diff --git a/vendor/github.com/urfave/cli/v2/altsrc/default_input_source.go b/vendor/github.com/urfave/cli/v2/altsrc/default_input_source.go new file mode 100644 index 00000000..7fda719b --- /dev/null +++ b/vendor/github.com/urfave/cli/v2/altsrc/default_input_source.go @@ -0,0 +1,6 @@ +package altsrc + +// defaultInputSource creates a default InputSourceContext. +func defaultInputSource() (InputSourceContext, error) { + return &MapInputSource{file: "", valueMap: map[interface{}]interface{}{}}, nil +} diff --git a/vendor/github.com/urfave/cli/v2/altsrc/fg.py b/vendor/github.com/urfave/cli/v2/altsrc/fg.py new file mode 100644 index 00000000..f0d150f1 --- /dev/null +++ b/vendor/github.com/urfave/cli/v2/altsrc/fg.py @@ -0,0 +1,45 @@ +# Only types that provide implementation of FlagInputSourceExtension can be listed here +# please keep list sorted alphabetically +flag_types = [ + "Bool", + "Duration", + "Float64", + "Generic", + "Int", + "IntSlice", + "Path", + "String", + "StringSlice", +] + +print('''// Code generated by fg.py; DO NOT EDIT. + +package altsrc + +import ( + "flag" + + "github.com/urfave/cli/v2" +)''') + +for t in flag_types: + print(f''' +// {t}Flag is the flag type that wraps cli.{t}Flag to allow +// for other values to be specified +type {t}Flag struct {{ + *cli.{t}Flag + set *flag.FlagSet +}} +var _ FlagInputSourceExtension = (*{t}Flag)(nil) + +// New{t}Flag creates a new {t}Flag +func New{t}Flag(fl *cli.{t}Flag) *{t}Flag {{ + return &{t}Flag{{{t}Flag: fl, set: nil}} +}} + +// Apply saves the flagSet for later usage calls, then calls +// the wrapped {t}Flag.Apply +func (f *{t}Flag) Apply(set *flag.FlagSet) error {{ + f.set = set + return f.{t}Flag.Apply(set) +}}''') \ No newline at end of file diff --git a/vendor/github.com/urfave/cli/v2/altsrc/flag.go b/vendor/github.com/urfave/cli/v2/altsrc/flag.go index 31b8a04e..36413216 100644 --- a/vendor/github.com/urfave/cli/v2/altsrc/flag.go +++ b/vendor/github.com/urfave/cli/v2/altsrc/flag.go @@ -64,7 +64,7 @@ func InitInputSourceWithContext(flags []cli.Flag, createInputSource func(context // ApplyInputSourceValue applies a generic value to the flagSet if required func (f *GenericFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { + if context != nil { if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVars) { value, err := isc.Generic(f.GenericFlag.Name) if err != nil { @@ -72,7 +72,7 @@ func (f *GenericFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourc } if value != nil { for _, name := range f.Names() { - _ = f.set.Set(name, value.String()) + _ = context.Set(name, value.String()) } } } @@ -83,7 +83,7 @@ func (f *GenericFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourc // ApplyInputSourceValue applies a StringSlice value to the flagSet if required func (f *StringSliceFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { + if context != nil { if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVars) { value, err := isc.StringSlice(f.StringSliceFlag.Name) if err != nil { @@ -94,6 +94,7 @@ func (f *StringSliceFlag) ApplyInputSourceValue(context *cli.Context, isc InputS for _, name := range f.Names() { underlyingFlag := f.set.Lookup(name) if underlyingFlag != nil { + context.Set(name, sliceValue.Serialize()) underlyingFlag.Value = &sliceValue } } @@ -105,7 +106,7 @@ func (f *StringSliceFlag) ApplyInputSourceValue(context *cli.Context, isc InputS // ApplyInputSourceValue applies a IntSlice value if required func (f *IntSliceFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { + if context != nil { if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVars) { value, err := isc.IntSlice(f.IntSliceFlag.Name) if err != nil { @@ -116,6 +117,7 @@ func (f *IntSliceFlag) ApplyInputSourceValue(context *cli.Context, isc InputSour for _, name := range f.Names() { underlyingFlag := f.set.Lookup(name) if underlyingFlag != nil { + context.Set(name, sliceValue.Serialize()) underlyingFlag.Value = &sliceValue } } @@ -127,7 +129,7 @@ func (f *IntSliceFlag) ApplyInputSourceValue(context *cli.Context, isc InputSour // ApplyInputSourceValue applies a Bool value to the flagSet if required func (f *BoolFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { + if context != nil { if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVars) { value, err := isc.Bool(f.BoolFlag.Name) if err != nil { @@ -135,7 +137,7 @@ func (f *BoolFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceCo } if value { for _, name := range f.Names() { - _ = f.set.Set(name, strconv.FormatBool(value)) + _ = context.Set(name, strconv.FormatBool(value)) } } } @@ -145,7 +147,7 @@ func (f *BoolFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceCo // ApplyInputSourceValue applies a String value to the flagSet if required func (f *StringFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { + if context != nil { if !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVars)) { value, err := isc.String(f.StringFlag.Name) if err != nil { @@ -153,7 +155,7 @@ func (f *StringFlag) ApplyInputSourceValue(context *cli.Context, isc InputSource } if value != "" { for _, name := range f.Names() { - _ = f.set.Set(name, value) + _ = context.Set(name, value) } } } @@ -163,7 +165,7 @@ func (f *StringFlag) ApplyInputSourceValue(context *cli.Context, isc InputSource // ApplyInputSourceValue applies a Path value to the flagSet if required func (f *PathFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { + if context != nil { if !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVars)) { value, err := isc.String(f.PathFlag.Name) if err != nil { @@ -181,7 +183,7 @@ func (f *PathFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceCo value = filepath.Join(filepath.Dir(basePathAbs), value) } - _ = f.set.Set(name, value) + _ = context.Set(name, value) } } } @@ -191,7 +193,7 @@ func (f *PathFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceCo // ApplyInputSourceValue applies a int value to the flagSet if required func (f *IntFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { + if context != nil { if !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVars)) { value, err := isc.Int(f.IntFlag.Name) if err != nil { @@ -199,7 +201,7 @@ func (f *IntFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceCon } if value > 0 { for _, name := range f.Names() { - _ = f.set.Set(name, strconv.FormatInt(int64(value), 10)) + _ = context.Set(name, strconv.FormatInt(int64(value), 10)) } } } @@ -209,7 +211,7 @@ func (f *IntFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceCon // ApplyInputSourceValue applies a Duration value to the flagSet if required func (f *DurationFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { + if context != nil { if !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVars)) { value, err := isc.Duration(f.DurationFlag.Name) if err != nil { @@ -217,7 +219,7 @@ func (f *DurationFlag) ApplyInputSourceValue(context *cli.Context, isc InputSour } if value > 0 { for _, name := range f.Names() { - _ = f.set.Set(name, value.String()) + _ = context.Set(name, value.String()) } } } @@ -227,7 +229,7 @@ func (f *DurationFlag) ApplyInputSourceValue(context *cli.Context, isc InputSour // ApplyInputSourceValue applies a Float64 value to the flagSet if required func (f *Float64Flag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error { - if f.set != nil { + if context != nil { if !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVars)) { value, err := isc.Float64(f.Float64Flag.Name) if err != nil { @@ -236,7 +238,7 @@ func (f *Float64Flag) ApplyInputSourceValue(context *cli.Context, isc InputSourc if value > 0 { floatStr := float64ToString(value) for _, name := range f.Names() { - _ = f.set.Set(name, floatStr) + _ = context.Set(name, floatStr) } } } diff --git a/vendor/github.com/urfave/cli/v2/altsrc/flag_generated.go b/vendor/github.com/urfave/cli/v2/altsrc/flag_generated.go index c9ecea82..bdaf5a5f 100644 --- a/vendor/github.com/urfave/cli/v2/altsrc/flag_generated.go +++ b/vendor/github.com/urfave/cli/v2/altsrc/flag_generated.go @@ -1,4 +1,4 @@ -// Code generated by fg; DO NOT EDIT. +// Code generated by fg.py; DO NOT EDIT. package altsrc @@ -14,6 +14,7 @@ type BoolFlag struct { *cli.BoolFlag set *flag.FlagSet } +var _ FlagInputSourceExtension = (*BoolFlag)(nil) // NewBoolFlag creates a new BoolFlag func NewBoolFlag(fl *cli.BoolFlag) *BoolFlag { @@ -33,6 +34,7 @@ type DurationFlag struct { *cli.DurationFlag set *flag.FlagSet } +var _ FlagInputSourceExtension = (*DurationFlag)(nil) // NewDurationFlag creates a new DurationFlag func NewDurationFlag(fl *cli.DurationFlag) *DurationFlag { @@ -52,6 +54,7 @@ type Float64Flag struct { *cli.Float64Flag set *flag.FlagSet } +var _ FlagInputSourceExtension = (*Float64Flag)(nil) // NewFloat64Flag creates a new Float64Flag func NewFloat64Flag(fl *cli.Float64Flag) *Float64Flag { @@ -71,6 +74,7 @@ type GenericFlag struct { *cli.GenericFlag set *flag.FlagSet } +var _ FlagInputSourceExtension = (*GenericFlag)(nil) // NewGenericFlag creates a new GenericFlag func NewGenericFlag(fl *cli.GenericFlag) *GenericFlag { @@ -84,31 +88,13 @@ func (f *GenericFlag) Apply(set *flag.FlagSet) error { return f.GenericFlag.Apply(set) } -// Int64Flag is the flag type that wraps cli.Int64Flag to allow -// for other values to be specified -type Int64Flag struct { - *cli.Int64Flag - set *flag.FlagSet -} - -// NewInt64Flag creates a new Int64Flag -func NewInt64Flag(fl *cli.Int64Flag) *Int64Flag { - return &Int64Flag{Int64Flag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls -// the wrapped Int64Flag.Apply -func (f *Int64Flag) Apply(set *flag.FlagSet) error { - f.set = set - return f.Int64Flag.Apply(set) -} - // IntFlag is the flag type that wraps cli.IntFlag to allow // for other values to be specified type IntFlag struct { *cli.IntFlag set *flag.FlagSet } +var _ FlagInputSourceExtension = (*IntFlag)(nil) // NewIntFlag creates a new IntFlag func NewIntFlag(fl *cli.IntFlag) *IntFlag { @@ -128,6 +114,7 @@ type IntSliceFlag struct { *cli.IntSliceFlag set *flag.FlagSet } +var _ FlagInputSourceExtension = (*IntSliceFlag)(nil) // NewIntSliceFlag creates a new IntSliceFlag func NewIntSliceFlag(fl *cli.IntSliceFlag) *IntSliceFlag { @@ -141,42 +128,24 @@ func (f *IntSliceFlag) Apply(set *flag.FlagSet) error { return f.IntSliceFlag.Apply(set) } -// Int64SliceFlag is the flag type that wraps cli.Int64SliceFlag to allow +// PathFlag is the flag type that wraps cli.PathFlag to allow // for other values to be specified -type Int64SliceFlag struct { - *cli.Int64SliceFlag +type PathFlag struct { + *cli.PathFlag set *flag.FlagSet } +var _ FlagInputSourceExtension = (*PathFlag)(nil) -// NewInt64SliceFlag creates a new Int64SliceFlag -func NewInt64SliceFlag(fl *cli.Int64SliceFlag) *Int64SliceFlag { - return &Int64SliceFlag{Int64SliceFlag: fl, set: nil} +// NewPathFlag creates a new PathFlag +func NewPathFlag(fl *cli.PathFlag) *PathFlag { + return &PathFlag{PathFlag: fl, set: nil} } // Apply saves the flagSet for later usage calls, then calls -// the wrapped Int64SliceFlag.Apply -func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error { +// the wrapped PathFlag.Apply +func (f *PathFlag) Apply(set *flag.FlagSet) error { f.set = set - return f.Int64SliceFlag.Apply(set) -} - -// Float64SliceFlag is the flag type that wraps cli.Float64SliceFlag to allow -// for other values to be specified -type Float64SliceFlag struct { - *cli.Float64SliceFlag - set *flag.FlagSet -} - -// NewFloat64SliceFlag creates a new Float64SliceFlag -func NewFloat64SliceFlag(fl *cli.Float64SliceFlag) *Float64SliceFlag { - return &Float64SliceFlag{Float64SliceFlag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped Float64SliceFlag.Apply -func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error { - f.set = set - return f.Float64SliceFlag.Apply(set) + return f.PathFlag.Apply(set) } // StringFlag is the flag type that wraps cli.StringFlag to allow @@ -185,6 +154,7 @@ type StringFlag struct { *cli.StringFlag set *flag.FlagSet } +var _ FlagInputSourceExtension = (*StringFlag)(nil) // NewStringFlag creates a new StringFlag func NewStringFlag(fl *cli.StringFlag) *StringFlag { @@ -198,31 +168,13 @@ func (f *StringFlag) Apply(set *flag.FlagSet) error { return f.StringFlag.Apply(set) } -// PathFlag is the flag type that wraps cli.PathFlag to allow -// for other values to be specified -type PathFlag struct { - *cli.PathFlag - set *flag.FlagSet -} - -// NewPathFlag creates a new PathFlag -func NewPathFlag(fl *cli.PathFlag) *PathFlag { - return &PathFlag{PathFlag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls the -// wrapped PathFlag.Apply -func (f *PathFlag) Apply(set *flag.FlagSet) error { - f.set = set - return f.PathFlag.Apply(set) -} - // StringSliceFlag is the flag type that wraps cli.StringSliceFlag to allow // for other values to be specified type StringSliceFlag struct { *cli.StringSliceFlag set *flag.FlagSet } +var _ FlagInputSourceExtension = (*StringSliceFlag)(nil) // NewStringSliceFlag creates a new StringSliceFlag func NewStringSliceFlag(fl *cli.StringSliceFlag) *StringSliceFlag { @@ -235,41 +187,3 @@ func (f *StringSliceFlag) Apply(set *flag.FlagSet) error { f.set = set return f.StringSliceFlag.Apply(set) } - -// Uint64Flag is the flag type that wraps cli.Uint64Flag to allow -// for other values to be specified -type Uint64Flag struct { - *cli.Uint64Flag - set *flag.FlagSet -} - -// NewUint64Flag creates a new Uint64Flag -func NewUint64Flag(fl *cli.Uint64Flag) *Uint64Flag { - return &Uint64Flag{Uint64Flag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls -// the wrapped Uint64Flag.Apply -func (f *Uint64Flag) Apply(set *flag.FlagSet) error { - f.set = set - return f.Uint64Flag.Apply(set) -} - -// UintFlag is the flag type that wraps cli.UintFlag to allow -// for other values to be specified -type UintFlag struct { - *cli.UintFlag - set *flag.FlagSet -} - -// NewUintFlag creates a new UintFlag -func NewUintFlag(fl *cli.UintFlag) *UintFlag { - return &UintFlag{UintFlag: fl, set: nil} -} - -// Apply saves the flagSet for later usage calls, then calls -// the wrapped UintFlag.Apply -func (f *UintFlag) Apply(set *flag.FlagSet) error { - f.set = set - return f.UintFlag.Apply(set) -} diff --git a/vendor/github.com/urfave/cli/v2/altsrc/json_source_context.go b/vendor/github.com/urfave/cli/v2/altsrc/json_source_context.go index 7d70a2a5..6e7bf11f 100644 --- a/vendor/github.com/urfave/cli/v2/altsrc/json_source_context.go +++ b/vendor/github.com/urfave/cli/v2/altsrc/json_source_context.go @@ -17,7 +17,11 @@ import ( // by the given flag. func NewJSONSourceFromFlagFunc(flag string) func(c *cli.Context) (InputSourceContext, error) { return func(context *cli.Context) (InputSourceContext, error) { - return NewJSONSourceFromFile(context.String(flag)) + if context.IsSet(flag) { + return NewJSONSourceFromFile(context.String(flag)) + } + + return defaultInputSource() } } diff --git a/vendor/github.com/urfave/cli/v2/altsrc/map_input_source.go b/vendor/github.com/urfave/cli/v2/altsrc/map_input_source.go index 661b7856..117461f5 100644 --- a/vendor/github.com/urfave/cli/v2/altsrc/map_input_source.go +++ b/vendor/github.com/urfave/cli/v2/altsrc/map_input_source.go @@ -16,6 +16,11 @@ type MapInputSource struct { valueMap map[interface{}]interface{} } +// NewMapInputSource creates a new MapInputSource for implementing custom input sources. +func NewMapInputSource(file string, valueMap map[interface{}]interface{}) *MapInputSource { + return &MapInputSource{file: file, valueMap: valueMap} +} + // nestedVal checks if the name has '.' delimiters. // If so, it tries to traverse the tree by the '.' delimited sections to find // a nested value for the key. diff --git a/vendor/github.com/urfave/cli/v2/altsrc/toml_file_loader.go b/vendor/github.com/urfave/cli/v2/altsrc/toml_file_loader.go index c679fdbe..9b86ee1a 100644 --- a/vendor/github.com/urfave/cli/v2/altsrc/toml_file_loader.go +++ b/vendor/github.com/urfave/cli/v2/altsrc/toml_file_loader.go @@ -87,8 +87,12 @@ func NewTomlSourceFromFile(file string) (InputSourceContext, error) { // NewTomlSourceFromFlagFunc creates a new TOML InputSourceContext from a provided flag name and source context. func NewTomlSourceFromFlagFunc(flagFileName string) func(context *cli.Context) (InputSourceContext, error) { return func(context *cli.Context) (InputSourceContext, error) { - filePath := context.String(flagFileName) - return NewTomlSourceFromFile(filePath) + if context.IsSet(flagFileName) { + filePath := context.String(flagFileName) + return NewTomlSourceFromFile(filePath) + } + + return defaultInputSource() } } diff --git a/vendor/github.com/urfave/cli/v2/altsrc/yaml_file_loader.go b/vendor/github.com/urfave/cli/v2/altsrc/yaml_file_loader.go index cf2f8a5c..a49df56f 100644 --- a/vendor/github.com/urfave/cli/v2/altsrc/yaml_file_loader.go +++ b/vendor/github.com/urfave/cli/v2/altsrc/yaml_file_loader.go @@ -33,8 +33,12 @@ func NewYamlSourceFromFile(file string) (InputSourceContext, error) { // NewYamlSourceFromFlagFunc creates a new Yaml InputSourceContext from a provided flag name and source context. func NewYamlSourceFromFlagFunc(flagFileName string) func(context *cli.Context) (InputSourceContext, error) { return func(context *cli.Context) (InputSourceContext, error) { - filePath := context.String(flagFileName) - return NewYamlSourceFromFile(filePath) + if context.IsSet(flagFileName) { + filePath := context.String(flagFileName) + return NewYamlSourceFromFile(filePath) + } + + return defaultInputSource() } } diff --git a/vendor/github.com/urfave/cli/v2/app.go b/vendor/github.com/urfave/cli/v2/app.go index d0c8f84e..2c972516 100644 --- a/vendor/github.com/urfave/cli/v2/app.go +++ b/vendor/github.com/urfave/cli/v2/app.go @@ -64,7 +64,7 @@ type App struct { Action ActionFunc // Execute this function if the proper command cannot be found CommandNotFound CommandNotFoundFunc - // Execute this function if an usage error occurs + // Execute this function if a usage error occurs OnUsageError OnUsageErrorFunc // Compilation date Compiled time.Time @@ -72,12 +72,15 @@ type App struct { Authors []*Author // Copyright of the binary if any Copyright string + // Reader reader to write input to (useful for tests) + Reader io.Reader // Writer writer to write output to Writer io.Writer // ErrWriter writes error output ErrWriter io.Writer - // Execute this function to handle ExitErrors. If not provided, HandleExitCoder is provided to - // function as a default, so this is optional. + // ExitErrHandler processes any error encountered while running an App before + // it is returned to the caller. If no function is provided, HandleExitCoder + // is used as the default behavior. ExitErrHandler ExitErrHandlerFunc // Other custom info Metadata map[string]interface{} @@ -116,7 +119,9 @@ func NewApp() *App { BashComplete: DefaultAppComplete, Action: helpCommand.Action, Compiled: compileTime(), + Reader: os.Stdin, Writer: os.Stdout, + ErrWriter: os.Stderr, } } @@ -135,7 +140,7 @@ func (a *App) Setup() { } if a.HelpName == "" { - a.HelpName = filepath.Base(os.Args[0]) + a.HelpName = a.Name } if a.Usage == "" { @@ -158,10 +163,18 @@ func (a *App) Setup() { a.Compiled = compileTime() } + if a.Reader == nil { + a.Reader = os.Stdin + } + if a.Writer == nil { a.Writer = os.Stdout } + if a.ErrWriter == nil { + a.ErrWriter = os.Stderr + } + var newCommands []*Command for _, c := range a.Commands { @@ -195,10 +208,6 @@ func (a *App) Setup() { if a.Metadata == nil { a.Metadata = make(map[string]interface{}) } - - if a.Writer == nil { - a.Writer = os.Stdout - } } func (a *App) newFlagSet() (*flag.FlagSet, error) { @@ -290,8 +299,6 @@ func (a *App) RunContext(ctx context.Context, arguments []string) (err error) { if a.Before != nil { beforeErr := a.Before(context) if beforeErr != nil { - _, _ = fmt.Fprintf(a.Writer, "%v\n\n", beforeErr) - _ = ShowAppHelp(context) a.handleExitCoder(context, beforeErr) err = beforeErr return err @@ -321,11 +328,11 @@ func (a *App) RunContext(ctx context.Context, arguments []string) (err error) { // RunAndExitOnError calls .Run() and exits non-zero if an error was returned // // Deprecated: instead you should return an error that fulfills cli.ExitCoder -// to cli.App.Run. This will cause the application to exit with the given eror +// to cli.App.Run. This will cause the application to exit with the given error // code in the cli.ExitCoder func (a *App) RunAndExitOnError() { if err := a.Run(os.Args); err != nil { - _, _ = fmt.Fprintln(a.errWriter(), err) + _, _ = fmt.Fprintln(a.ErrWriter, err) OsExiter(1) } } @@ -479,15 +486,6 @@ func (a *App) VisibleFlags() []Flag { return visibleFlags(a.Flags) } -func (a *App) errWriter() io.Writer { - // When the app ErrWriter is nil use the package level one. - if a.ErrWriter == nil { - return ErrWriter - } - - return a.ErrWriter -} - func (a *App) appendFlag(fl Flag) { if !hasFlag(a.Flags, fl) { a.Flags = append(a.Flags, fl) diff --git a/vendor/github.com/urfave/cli/v2/command.go b/vendor/github.com/urfave/cli/v2/command.go index 95840f32..3503a555 100644 --- a/vendor/github.com/urfave/cli/v2/command.go +++ b/vendor/github.com/urfave/cli/v2/command.go @@ -150,7 +150,6 @@ func (c *Command) Run(ctx *Context) (err error) { if c.Before != nil { err = c.Before(context) if err != nil { - _ = ShowCommandHelp(context, c.Name) context.App.handleExitCoder(context, err) return err } @@ -242,8 +241,9 @@ func (c *Command) startApp(ctx *Context) error { app.HideHelpCommand = c.HideHelpCommand app.Version = ctx.App.Version - app.HideVersion = ctx.App.HideVersion + app.HideVersion = true app.Compiled = ctx.App.Compiled + app.Reader = ctx.App.Reader app.Writer = ctx.App.Writer app.ErrWriter = ctx.App.ErrWriter app.ExitErrHandler = ctx.App.ExitErrHandler diff --git a/vendor/github.com/urfave/cli/v2/context.go b/vendor/github.com/urfave/cli/v2/context.go index 74ed5191..05099e93 100644 --- a/vendor/github.com/urfave/cli/v2/context.go +++ b/vendor/github.com/urfave/cli/v2/context.go @@ -18,6 +18,7 @@ type Context struct { Command *Command shellComplete bool flagSet *flag.FlagSet + fromFlagSet map[string]bool parentContext *Context } @@ -32,6 +33,14 @@ func NewContext(app *App, set *flag.FlagSet, parentCtx *Context) *Context { } } + // pre-compute flag seen on the command line at this context + c.fromFlagSet = make(map[string]bool) + if set != nil { + set.Visit(func(f *flag.Flag) { + c.fromFlagSet[f.Name] = true + }) + } + c.Command = &Command{} if c.Context == nil { @@ -48,35 +57,50 @@ func (c *Context) NumFlags() int { // Set sets a context flag to a value. func (c *Context) Set(name, value string) error { - return c.flagSet.Set(name, value) + err := c.flagSet.Set(name, value) + if err == nil { + c.fromFlagSet[name] = true + } + + return err } // IsSet determines if the flag was actually set func (c *Context) IsSet(name string) bool { - if fs := lookupFlagSet(name, c); fs != nil { - if fs := lookupFlagSet(name, c); fs != nil { - isSet := false - fs.Visit(func(f *flag.Flag) { - if f.Name == name { - isSet = true + for ctx := c; ctx != nil; ctx = ctx.parentContext { + // try flags parsed from command line first + if ctx.flagSet.Lookup(name) == nil { + // flag not defined in this context + continue + } + if ctx.flagOnCommandLine(name) { + return true + } + + // now see if value was set externally via environment + definedFlags := ctx.Command.Flags + if ctx.Command.Name == "" && ctx.App != nil { + definedFlags = ctx.App.Flags + } + for _, ff := range definedFlags { + for _, fn := range ff.Names() { + if fn == name { + if ff.IsSet() { + return true + } + break } - }) - if isSet { - return true } } - - f := lookupFlag(name, c) - if f == nil { - return false - } - - return f.IsSet() } return false } +func (c *Context) flagOnCommandLine(name string) bool { + return c.fromFlagSet[name] +} + // LocalFlagNames returns a slice of flag names used in this context. func (c *Context) LocalFlagNames() []string { var names []string @@ -108,7 +132,10 @@ func (c *Context) Lineage() []*Context { // Value returns the value of the flag corresponding to `name` func (c *Context) Value(name string) interface{} { - return c.flagSet.Lookup(name).Value.(flag.Getter).Get() + if fs := lookupFlagSet(name, c); fs != nil { + return fs.Lookup(name).Value.(flag.Getter).Get() + } + return nil } // Args returns the command line arguments associated with the context. @@ -150,6 +177,25 @@ func lookupFlag(name string, ctx *Context) Flag { return nil } +func (c *Context) resolveFlagDeep(name string) *flag.Flag { + var src *flag.Flag + for cur := c; cur != nil; cur = cur.parentContext { + if f := cur.flagSet.Lookup(name); f != nil { + if cur.flagOnCommandLine(name) { + // we've found most specific instance on command line, use it + src = f + break + } + if src == nil { + // flag was defined, but value is not present among flags of the current context + // remember the most specific instance of the flag not from command line as fallback + src = f + } + } + } + return src +} + func lookupFlagSet(name string, ctx *Context) *flag.FlagSet { for _, c := range ctx.Lineage() { if f := c.flagSet.Lookup(name); f != nil { diff --git a/vendor/github.com/urfave/cli/v2/docs.go b/vendor/github.com/urfave/cli/v2/docs.go index dc16fc82..4c0e1f67 100644 --- a/vendor/github.com/urfave/cli/v2/docs.go +++ b/vendor/github.com/urfave/cli/v2/docs.go @@ -15,31 +15,39 @@ import ( // The function errors if either parsing or writing of the string fails. func (a *App) ToMarkdown() (string, error) { var w bytes.Buffer - if err := a.writeDocTemplate(&w); err != nil { + if err := a.writeDocTemplate(&w, 8); err != nil { return "", err } return w.String(), nil } -// ToMan creates a man page string for the `*App` +// ToMan creates a man page string with section number for the `*App` // The function errors if either parsing or writing of the string fails. -func (a *App) ToMan() (string, error) { +func (a *App) ToManWithSection(sectionNumber int) (string, error) { var w bytes.Buffer - if err := a.writeDocTemplate(&w); err != nil { + if err := a.writeDocTemplate(&w, sectionNumber); err != nil { return "", err } man := md2man.Render(w.Bytes()) return string(man), nil } +// ToMan creates a man page string for the `*App` +// The function errors if either parsing or writing of the string fails. +func (a *App) ToMan() (string, error) { + man, err := a.ToManWithSection(8) + return man, err +} + type cliTemplate struct { App *App + SectionNum int Commands []string GlobalArgs []string SynopsisArgs []string } -func (a *App) writeDocTemplate(w io.Writer) error { +func (a *App) writeDocTemplate(w io.Writer, sectionNum int) error { const name = "cli" t, err := template.New(name).Parse(MarkdownDocTemplate) if err != nil { @@ -47,6 +55,7 @@ func (a *App) writeDocTemplate(w io.Writer) error { } return t.ExecuteTemplate(w, name, &cliTemplate{ App: a, + SectionNum: sectionNum, Commands: prepareCommands(a.Commands, 0), GlobalArgs: prepareArgsWithValues(a.VisibleFlags()), SynopsisArgs: prepareArgsSynopsis(a.VisibleFlags()), diff --git a/vendor/github.com/urfave/cli/v2/errors.go b/vendor/github.com/urfave/cli/v2/errors.go index 344b4361..751ef9b1 100644 --- a/vendor/github.com/urfave/cli/v2/errors.go +++ b/vendor/github.com/urfave/cli/v2/errors.go @@ -17,11 +17,10 @@ var ErrWriter io.Writer = os.Stderr // MultiError is an error that wraps multiple errors. type MultiError interface { error - // Errors returns a copy of the errors slice Errors() []error } -// NewMultiError creates a new MultiError. Pass in one or more errors. +// newMultiError creates a new MultiError. Pass in one or more errors. func newMultiError(err ...error) MultiError { ret := multiError(err) return &ret @@ -65,13 +64,20 @@ type exitError struct { message interface{} } -// NewExitError makes a new *exitError +// NewExitError calls Exit to create a new ExitCoder. +// +// Deprecated: This function is a duplicate of Exit and will eventually be removed. func NewExitError(message interface{}, exitCode int) ExitCoder { return Exit(message, exitCode) } -// Exit wraps a message and exit code into an ExitCoder suitable for handling by -// HandleExitCoder +// Exit wraps a message and exit code into an error, which by default is +// handled with a call to os.Exit during default error handling. +// +// This is the simplest way to trigger a non-zero exit code for an App without +// having to call os.Exit manually. During testing, this behavior can be avoided +// by overiding the ExitErrHandler function on an App or the package-global +// OsExiter function. func Exit(message interface{}, exitCode int) ExitCoder { return &exitError{ message: message, @@ -87,10 +93,14 @@ func (ee *exitError) ExitCode() int { return ee.exitCode } -// HandleExitCoder checks if the error fulfills the ExitCoder interface, and if -// so prints the error to stderr (if it is non-empty) and calls OsExiter with the -// given exit code. If the given error is a MultiError, then this func is -// called on all members of the Errors slice and calls OsExiter with the last exit code. +// HandleExitCoder handles errors implementing ExitCoder by printing their +// message and calling OsExiter with the given exit code. +// +// If the given error instead implements MultiError, each error will be checked +// for the ExitCoder interface, and OsExiter will be called with the last exit +// code found, or exit code 1 if no ExitCoder is found. +// +// This function is the default error-handling behavior for an App. func HandleExitCoder(err error) { if err == nil { return diff --git a/vendor/github.com/urfave/cli/v2/fish.go b/vendor/github.com/urfave/cli/v2/fish.go index 67122c9f..588e070e 100644 --- a/vendor/github.com/urfave/cli/v2/fish.go +++ b/vendor/github.com/urfave/cli/v2/fish.go @@ -171,6 +171,10 @@ func fishAddFileFlag(flag Flag, completion *strings.Builder) { if f.TakesFile { return } + case *PathFlag: + if f.TakesFile { + return + } } completion.WriteString(" -f") } diff --git a/vendor/github.com/urfave/cli/v2/flag.go b/vendor/github.com/urfave/cli/v2/flag.go index ad97c2d0..aff8d5be 100644 --- a/vendor/github.com/urfave/cli/v2/flag.go +++ b/vendor/github.com/urfave/cli/v2/flag.go @@ -359,7 +359,11 @@ func stringifySliceFlag(usage string, names, defaultVals []string) string { } usageWithDefault := strings.TrimSpace(fmt.Sprintf("%s%s", usage, defaultVal)) - return fmt.Sprintf("%s\t%s", prefixedNames(names, placeholder), usageWithDefault) + multiInputString := "(accepts multiple inputs)" + if usageWithDefault != "" { + multiInputString = "\t" + multiInputString + } + return fmt.Sprintf("%s\t%s%s", prefixedNames(names, placeholder), usageWithDefault, multiInputString) } func hasFlag(flags []Flag, fl Flag) bool { diff --git a/vendor/github.com/urfave/cli/v2/flag_bool.go b/vendor/github.com/urfave/cli/v2/flag_bool.go index bc9ea35d..41fb2e35 100644 --- a/vendor/github.com/urfave/cli/v2/flag_bool.go +++ b/vendor/github.com/urfave/cli/v2/flag_bool.go @@ -87,14 +87,10 @@ func (f *BoolFlag) Apply(set *flag.FlagSet) error { // Bool looks up the value of a local BoolFlag, returns // false if not found func (c *Context) Bool(name string) bool { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupBool(name, fs) - } - return false + return lookupBool(c.resolveFlagDeep(name)) } -func lookupBool(name string, set *flag.FlagSet) bool { - f := set.Lookup(name) +func lookupBool(f *flag.Flag) bool { if f != nil { parsed, err := strconv.ParseBool(f.Value.String()) if err != nil { diff --git a/vendor/github.com/urfave/cli/v2/flag_duration.go b/vendor/github.com/urfave/cli/v2/flag_duration.go index 22a2e672..bfffd16b 100644 --- a/vendor/github.com/urfave/cli/v2/flag_duration.go +++ b/vendor/github.com/urfave/cli/v2/flag_duration.go @@ -86,14 +86,10 @@ func (f *DurationFlag) Apply(set *flag.FlagSet) error { // Duration looks up the value of a local DurationFlag, returns // 0 if not found func (c *Context) Duration(name string) time.Duration { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupDuration(name, fs) - } - return 0 + return lookupDuration(c.resolveFlagDeep(name)) } -func lookupDuration(name string, set *flag.FlagSet) time.Duration { - f := set.Lookup(name) +func lookupDuration(f *flag.Flag) time.Duration { if f != nil { parsed, err := time.ParseDuration(f.Value.String()) if err != nil { diff --git a/vendor/github.com/urfave/cli/v2/flag_float64.go b/vendor/github.com/urfave/cli/v2/flag_float64.go index 91c778c8..f743caad 100644 --- a/vendor/github.com/urfave/cli/v2/flag_float64.go +++ b/vendor/github.com/urfave/cli/v2/flag_float64.go @@ -87,14 +87,10 @@ func (f *Float64Flag) Apply(set *flag.FlagSet) error { // Float64 looks up the value of a local Float64Flag, returns // 0 if not found func (c *Context) Float64(name string) float64 { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupFloat64(name, fs) - } - return 0 + return lookupFloat64(c.resolveFlagDeep(name)) } -func lookupFloat64(name string, set *flag.FlagSet) float64 { - f := set.Lookup(name) +func lookupFloat64(f *flag.Flag) float64 { if f != nil { parsed, err := strconv.ParseFloat(f.Value.String(), 64) if err != nil { diff --git a/vendor/github.com/urfave/cli/v2/flag_float64_slice.go b/vendor/github.com/urfave/cli/v2/flag_float64_slice.go index 706ee6cd..27090838 100644 --- a/vendor/github.com/urfave/cli/v2/flag_float64_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_float64_slice.go @@ -146,14 +146,10 @@ func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error { // Float64Slice looks up the value of a local Float64SliceFlag, returns // nil if not found func (c *Context) Float64Slice(name string) []float64 { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupFloat64Slice(name, fs) - } - return nil + return lookupFloat64Slice(c.resolveFlagDeep(name)) } -func lookupFloat64Slice(name string, set *flag.FlagSet) []float64 { - f := set.Lookup(name) +func lookupFloat64Slice(f *flag.Flag) []float64 { if f != nil { if slice, ok := f.Value.(*Float64Slice); ok { return slice.Value() diff --git a/vendor/github.com/urfave/cli/v2/flag_generic.go b/vendor/github.com/urfave/cli/v2/flag_generic.go index b0c8ff44..e5a24e3a 100644 --- a/vendor/github.com/urfave/cli/v2/flag_generic.go +++ b/vendor/github.com/urfave/cli/v2/flag_generic.go @@ -68,7 +68,7 @@ func (f *GenericFlag) GetValue() string { // Apply takes the flagset and calls Set on the generic flag with the value // provided by the user for parsing by the flag -func (f GenericFlag) Apply(set *flag.FlagSet) error { +func (f *GenericFlag) Apply(set *flag.FlagSet) error { if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok { if val != "" { if err := f.Value.Set(val); err != nil { @@ -89,14 +89,10 @@ func (f GenericFlag) Apply(set *flag.FlagSet) error { // Generic looks up the value of a local GenericFlag, returns // nil if not found func (c *Context) Generic(name string) interface{} { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupGeneric(name, fs) - } - return nil + return lookupGeneric(c.resolveFlagDeep(name)) } -func lookupGeneric(name string, set *flag.FlagSet) interface{} { - f := set.Lookup(name) +func lookupGeneric(f *flag.Flag) interface{} { if f != nil { parsed, err := f.Value, error(nil) if err != nil { diff --git a/vendor/github.com/urfave/cli/v2/flag_int.go b/vendor/github.com/urfave/cli/v2/flag_int.go index ac39d4a9..706353de 100644 --- a/vendor/github.com/urfave/cli/v2/flag_int.go +++ b/vendor/github.com/urfave/cli/v2/flag_int.go @@ -87,14 +87,10 @@ func (f *IntFlag) Apply(set *flag.FlagSet) error { // Int looks up the value of a local IntFlag, returns // 0 if not found func (c *Context) Int(name string) int { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupInt(name, fs) - } - return 0 + return lookupInt(c.resolveFlagDeep(name)) } -func lookupInt(name string, set *flag.FlagSet) int { - f := set.Lookup(name) +func lookupInt(f *flag.Flag) int { if f != nil { parsed, err := strconv.ParseInt(f.Value.String(), 0, 64) if err != nil { diff --git a/vendor/github.com/urfave/cli/v2/flag_int64.go b/vendor/github.com/urfave/cli/v2/flag_int64.go index e0999126..74f9a84b 100644 --- a/vendor/github.com/urfave/cli/v2/flag_int64.go +++ b/vendor/github.com/urfave/cli/v2/flag_int64.go @@ -86,14 +86,10 @@ func (f *Int64Flag) Apply(set *flag.FlagSet) error { // Int64 looks up the value of a local Int64Flag, returns // 0 if not found func (c *Context) Int64(name string) int64 { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupInt64(name, fs) - } - return 0 + return lookupInt64(c.resolveFlagDeep(name)) } -func lookupInt64(name string, set *flag.FlagSet) int64 { - f := set.Lookup(name) +func lookupInt64(f *flag.Flag) int64 { if f != nil { parsed, err := strconv.ParseInt(f.Value.String(), 0, 64) if err != nil { diff --git a/vendor/github.com/urfave/cli/v2/flag_int64_slice.go b/vendor/github.com/urfave/cli/v2/flag_int64_slice.go index 6c7fd937..6f1942f4 100644 --- a/vendor/github.com/urfave/cli/v2/flag_int64_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_int64_slice.go @@ -145,11 +145,10 @@ func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error { // Int64Slice looks up the value of a local Int64SliceFlag, returns // nil if not found func (c *Context) Int64Slice(name string) []int64 { - return lookupInt64Slice(name, c.flagSet) + return lookupInt64Slice(c.resolveFlagDeep(name)) } -func lookupInt64Slice(name string, set *flag.FlagSet) []int64 { - f := set.Lookup(name) +func lookupInt64Slice(f *flag.Flag) []int64 { if f != nil { if slice, ok := f.Value.(*Int64Slice); ok { return slice.Value() diff --git a/vendor/github.com/urfave/cli/v2/flag_int_slice.go b/vendor/github.com/urfave/cli/v2/flag_int_slice.go index 4e0afc02..6e42e77e 100644 --- a/vendor/github.com/urfave/cli/v2/flag_int_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_int_slice.go @@ -156,14 +156,10 @@ func (f *IntSliceFlag) Apply(set *flag.FlagSet) error { // IntSlice looks up the value of a local IntSliceFlag, returns // nil if not found func (c *Context) IntSlice(name string) []int { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupIntSlice(name, c.flagSet) - } - return nil + return lookupIntSlice(c.resolveFlagDeep(name)) } -func lookupIntSlice(name string, set *flag.FlagSet) []int { - f := set.Lookup(name) +func lookupIntSlice(f *flag.Flag) []int { if f != nil { if slice, ok := f.Value.(*IntSlice); ok { return slice.Value() diff --git a/vendor/github.com/urfave/cli/v2/flag_path.go b/vendor/github.com/urfave/cli/v2/flag_path.go index 8070dc4b..21b1dd49 100644 --- a/vendor/github.com/urfave/cli/v2/flag_path.go +++ b/vendor/github.com/urfave/cli/v2/flag_path.go @@ -75,15 +75,10 @@ func (f *PathFlag) Apply(set *flag.FlagSet) error { // Path looks up the value of a local PathFlag, returns // "" if not found func (c *Context) Path(name string) string { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupPath(name, fs) - } - - return "" + return lookupPath(c.resolveFlagDeep(name)) } -func lookupPath(name string, set *flag.FlagSet) string { - f := set.Lookup(name) +func lookupPath(f *flag.Flag) string { if f != nil { parsed, err := f.Value.String(), error(nil) if err != nil { diff --git a/vendor/github.com/urfave/cli/v2/flag_string.go b/vendor/github.com/urfave/cli/v2/flag_string.go index 400bb532..60363de2 100644 --- a/vendor/github.com/urfave/cli/v2/flag_string.go +++ b/vendor/github.com/urfave/cli/v2/flag_string.go @@ -76,14 +76,10 @@ func (f *StringFlag) Apply(set *flag.FlagSet) error { // String looks up the value of a local StringFlag, returns // "" if not found func (c *Context) String(name string) string { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupString(name, fs) - } - return "" + return lookupString(c.resolveFlagDeep(name)) } -func lookupString(name string, set *flag.FlagSet) string { - f := set.Lookup(name) +func lookupString(f *flag.Flag) string { if f != nil { parsed, err := f.Value.String(), error(nil) if err != nil { diff --git a/vendor/github.com/urfave/cli/v2/flag_string_slice.go b/vendor/github.com/urfave/cli/v2/flag_string_slice.go index ac363bf6..a8c55f43 100644 --- a/vendor/github.com/urfave/cli/v2/flag_string_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_string_slice.go @@ -116,8 +116,17 @@ func (f *StringSliceFlag) GetValue() string { // Apply populates the flag given the flag set and environment func (f *StringSliceFlag) Apply(set *flag.FlagSet) error { + + if f.Destination != nil && f.Value != nil { + f.Destination.slice = make([]string, len(f.Value.slice)) + copy(f.Destination.slice, f.Value.slice) + + } + if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok { - f.Value = &StringSlice{} + if f.Value == nil { + f.Value = &StringSlice{} + } destination := f.Value if f.Destination != nil { destination = f.Destination @@ -154,14 +163,10 @@ func (f *StringSliceFlag) Apply(set *flag.FlagSet) error { // StringSlice looks up the value of a local StringSliceFlag, returns // nil if not found func (c *Context) StringSlice(name string) []string { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupStringSlice(name, fs) - } - return nil + return lookupStringSlice(c.resolveFlagDeep(name)) } -func lookupStringSlice(name string, set *flag.FlagSet) []string { - f := set.Lookup(name) +func lookupStringSlice(f *flag.Flag) []string { if f != nil { if slice, ok := f.Value.(*StringSlice); ok { return slice.Value() diff --git a/vendor/github.com/urfave/cli/v2/flag_timestamp.go b/vendor/github.com/urfave/cli/v2/flag_timestamp.go index 9fac1d1e..2fe73944 100644 --- a/vendor/github.com/urfave/cli/v2/flag_timestamp.go +++ b/vendor/github.com/urfave/cli/v2/flag_timestamp.go @@ -118,7 +118,9 @@ func (f *TimestampFlag) Apply(set *flag.FlagSet) error { if f.Layout == "" { return fmt.Errorf("timestamp Layout is required") } - f.Value = &Timestamp{} + if f.Value == nil { + f.Value = &Timestamp{} + } f.Value.SetLayout(f.Layout) if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok { @@ -136,15 +138,11 @@ func (f *TimestampFlag) Apply(set *flag.FlagSet) error { // Timestamp gets the timestamp from a flag name func (c *Context) Timestamp(name string) *time.Time { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupTimestamp(name, fs) - } - return nil + return lookupTimestamp(c.resolveFlagDeep(name)) } // Fetches the timestamp value from the local timestampWrap -func lookupTimestamp(name string, set *flag.FlagSet) *time.Time { - f := set.Lookup(name) +func lookupTimestamp(f *flag.Flag) *time.Time { if f != nil { return (f.Value.(*Timestamp)).Value() } diff --git a/vendor/github.com/urfave/cli/v2/flag_uint.go b/vendor/github.com/urfave/cli/v2/flag_uint.go index 2e5e76b0..6a128f5e 100644 --- a/vendor/github.com/urfave/cli/v2/flag_uint.go +++ b/vendor/github.com/urfave/cli/v2/flag_uint.go @@ -86,14 +86,10 @@ func (f *UintFlag) GetValue() string { // Uint looks up the value of a local UintFlag, returns // 0 if not found func (c *Context) Uint(name string) uint { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupUint(name, fs) - } - return 0 + return lookupUint(c.resolveFlagDeep(name)) } -func lookupUint(name string, set *flag.FlagSet) uint { - f := set.Lookup(name) +func lookupUint(f *flag.Flag) uint { if f != nil { parsed, err := strconv.ParseUint(f.Value.String(), 0, 64) if err != nil { diff --git a/vendor/github.com/urfave/cli/v2/flag_uint64.go b/vendor/github.com/urfave/cli/v2/flag_uint64.go index 8fc3289d..7545b1d6 100644 --- a/vendor/github.com/urfave/cli/v2/flag_uint64.go +++ b/vendor/github.com/urfave/cli/v2/flag_uint64.go @@ -86,14 +86,10 @@ func (f *Uint64Flag) GetValue() string { // Uint64 looks up the value of a local Uint64Flag, returns // 0 if not found func (c *Context) Uint64(name string) uint64 { - if fs := lookupFlagSet(name, c); fs != nil { - return lookupUint64(name, fs) - } - return 0 + return lookupUint64(c.resolveFlagDeep(name)) } -func lookupUint64(name string, set *flag.FlagSet) uint64 { - f := set.Lookup(name) +func lookupUint64(f *flag.Flag) uint64 { if f != nil { parsed, err := strconv.ParseUint(f.Value.String(), 0, 64) if err != nil { diff --git a/vendor/github.com/urfave/cli/v2/go.mod b/vendor/github.com/urfave/cli/v2/go.mod index c38d41c1..11396643 100644 --- a/vendor/github.com/urfave/cli/v2/go.mod +++ b/vendor/github.com/urfave/cli/v2/go.mod @@ -5,5 +5,5 @@ go 1.11 require ( github.com/BurntSushi/toml v0.3.1 github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d - gopkg.in/yaml.v2 v2.2.2 + gopkg.in/yaml.v2 v2.2.3 ) diff --git a/vendor/github.com/urfave/cli/v2/go.sum b/vendor/github.com/urfave/cli/v2/go.sum index ef121ff5..663ad727 100644 --- a/vendor/github.com/urfave/cli/v2/go.sum +++ b/vendor/github.com/urfave/cli/v2/go.sum @@ -10,5 +10,5 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5I github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/urfave/cli/v2/help.go b/vendor/github.com/urfave/cli/v2/help.go index c1e974a4..0a421ee9 100644 --- a/vendor/github.com/urfave/cli/v2/help.go +++ b/vendor/github.com/urfave/cli/v2/help.go @@ -72,13 +72,13 @@ func ShowAppHelpAndExit(c *Context, exitCode int) { // ShowAppHelp is an action that displays the help. func ShowAppHelp(c *Context) error { - template := c.App.CustomAppHelpTemplate - if template == "" { - template = AppHelpTemplate + tpl := c.App.CustomAppHelpTemplate + if tpl == "" { + tpl = AppHelpTemplate } if c.App.ExtraInfo == nil { - HelpPrinter(c.App.Writer, template, c.App) + HelpPrinter(c.App.Writer, tpl, c.App) return nil } @@ -87,7 +87,7 @@ func ShowAppHelp(c *Context) error { "ExtraInfo": c.App.ExtraInfo, } } - HelpPrinterCustom(c.App.Writer, template, c.App, customAppData()) + HelpPrinterCustom(c.App.Writer, tpl, c.App, customAppData()) return nil } @@ -214,6 +214,12 @@ func ShowCommandHelp(ctx *Context, command string) error { return nil } +// ShowSubcommandHelpAndExit - Prints help for the given subcommand and exits with exit code. +func ShowSubcommandHelpAndExit(c *Context, exitCode int) { + _ = ShowSubcommandHelp(c) + os.Exit(exitCode) +} + // ShowSubcommandHelp prints help for the given subcommand func ShowSubcommandHelp(c *Context) error { if c == nil { @@ -263,7 +269,10 @@ func ShowCommandCompletions(ctx *Context, command string) { // allow using arbitrary functions in template rendering. func printHelpCustom(out io.Writer, templ string, data interface{}, customFuncs map[string]interface{}) { funcMap := template.FuncMap{ - "join": strings.Join, + "join": strings.Join, + "indent": indent, + "nindent": nindent, + "trim": strings.TrimSpace, } for key, value := range customFuncs { funcMap[key] = value @@ -366,3 +375,12 @@ func checkCommandCompletions(c *Context, name string) bool { ShowCommandCompletions(c, name) return true } + +func indent(spaces int, v string) string { + pad := strings.Repeat(" ", spaces) + return pad + strings.Replace(v, "\n", "\n"+pad, -1) +} + +func nindent(spaces int, v string) string { + return "\n" + indent(spaces, v) +} diff --git a/vendor/github.com/urfave/cli/v2/template.go b/vendor/github.com/urfave/cli/v2/template.go index aee3e049..317cc881 100644 --- a/vendor/github.com/urfave/cli/v2/template.go +++ b/vendor/github.com/urfave/cli/v2/template.go @@ -13,7 +13,7 @@ VERSION: {{.Version}}{{end}}{{end}}{{if .Description}} DESCRIPTION: - {{.Description}}{{end}}{{if len .Authors}} + {{.Description | nindent 3 | trim}}{{end}}{{if len .Authors}} AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}: {{range $index, $author := .Authors}}{{if $index}} @@ -45,7 +45,7 @@ CATEGORY: {{.Category}}{{end}}{{if .Description}} DESCRIPTION: - {{.Description}}{{end}}{{if .VisibleFlags}} + {{.Description | nindent 3 | trim}}{{end}}{{if .VisibleFlags}} OPTIONS: {{range .VisibleFlags}}{{.}} @@ -62,7 +62,7 @@ USAGE: {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Description}} DESCRIPTION: - {{.Description}}{{end}} + {{.Description | nindent 3 | trim}}{{end}} COMMANDS:{{range .VisibleCategories}}{{if .Name}} {{.Name}}:{{range .VisibleCommands}} @@ -74,7 +74,7 @@ OPTIONS: {{end}}{{end}} ` -var MarkdownDocTemplate = `% {{ .App.Name }} 8 +var MarkdownDocTemplate = `% {{ .App.Name }} {{ .SectionNum }} # NAME diff --git a/vendor/modules.txt b/vendor/modules.txt index 89d373c1..5eb0b272 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -246,7 +246,7 @@ github.com/shurcooL/sanitized_anchor_name ## explicit github.com/stretchr/testify/assert github.com/stretchr/testify/require -# github.com/urfave/cli/v2 v2.2.0 +# github.com/urfave/cli/v2 v2.2.0 => github.com/ipostelnik/cli/v2 v2.3.1-0.20210223162147-c8b4f97735e4 ## explicit github.com/urfave/cli/v2 github.com/urfave/cli/v2/altsrc @@ -431,3 +431,4 @@ zombiezen.com/go/capnproto2/rpc/internal/refcount zombiezen.com/go/capnproto2/schemas zombiezen.com/go/capnproto2/server zombiezen.com/go/capnproto2/std/capnp/rpc +# github.com/urfave/cli/v2 => github.com/ipostelnik/cli/v2 v2.3.1-0.20210223162147-c8b4f97735e4