Using the `app help <subcommand>` doesn't show the default values for flags
smbl64 opened this issue · 2 comments
smbl64 commented
My urfave/cli version is
v2.25.7
Checklist
- Are you running the latest v2 release? The list of releases is here.
- Did you check the manual for your release? The v2 manual is here
- Did you perform a search about this problem? Here's the GitHub guide about searching.
Dependency Management
- My project is using go modules.
- My project is automatically downloading the latest version.
Describe the bug
When a command's flags have their Value
set, app help <subcommand>
doesn't show those default values, while app <subcommand> --help
works correctly.
To reproduce
- Create a command with flags that have default values.
- Use
app help <command>
to produce a help output.
Observed behavior
app help <command>
shows zero values for the flags.
Expected behavior
app help <command>
must show the default values set for those flags.
Additional context
I have created a sample program on Go playground.
These are the outputs that I get when generating help:
$ go run . help greet
NAME:
hello greet - Greets you with your age
USAGE:
hello greet [command options] [arguments...]
OPTIONS:
--name value
--age value (default: 0)
--help, -h show help
$ go run . greet -h
NAME:
hello greet - Greets you with your age
USAGE:
hello greet [command options] [arguments...]
OPTIONS:
--name value (default: "Foo")
--age value (default: 40)
--help, -h show help
Want to fix this yourself?
We'd love to have more contributors on this project! If the fix for
this bug is easily explained and very small, feel free to create a
pull request for it.
Run go version
and paste its output here
go version go1.21.0 darwin/arm64
Run go env
and paste its output here
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/mohammad/Library/Caches/go-build'
GOENV='/Users/mohammad/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/mohammad/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/mohammad/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/mohammad/.local/share/rtx/installs/go/1.21.0/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/mohammad/.local/share/rtx/installs/go/1.21.0/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/private/tmp/cli_test/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/7l/4xj8m_w94qd0m1hl_z03bljc0000gp/T/go-build383094992=/tmp/go-build -gno-record-gcc-switches -fno-common'