Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the app help <subcommand> doesn't show the default values for flags #1808

Closed
3 tasks done
smbl64 opened this issue Aug 28, 2023 · 2 comments
Closed
3 tasks done
Labels
area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug status/triage maintainers still need to look into this status/waiting-for-response Waiting for response from original requester

Comments

@smbl64
Copy link

smbl64 commented Aug 28, 2023

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

  1. Create a command with flags that have default values.
  2. 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'

@smbl64 smbl64 added area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug status/triage maintainers still need to look into this labels Aug 28, 2023
@dearchap dearchap added the status/waiting-for-response Waiting for response from original requester label Nov 29, 2023
@dearchap
Copy link
Contributor

@smbl64 Please try the PR fix

@smbl64
Copy link
Author

smbl64 commented Dec 2, 2023

Thank you @dearchap! The problem is resolved 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug status/triage maintainers still need to look into this status/waiting-for-response Waiting for response from original requester
Projects
None yet
Development

No branches or pull requests

2 participants