Default `cli.App.Usage` behaviour is very hard to override and leads to ugly help
Amaury-Behague opened this issue · comments
My urfave/cli version is
v2.27.2
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 (this is broken btw)
- Did you perform a search about this problem? Here's the GitHub guide about searching.
Dependency Management
- My project is using go modules.
Describe the bug
This line of the code doesn't allow to set an empty cli.App.Usage
value, which together with the fact that helpNameTemplate
is not configurable makes it hard to have a clean HELP:
section in the CLI docs.
Line 203 in 1210bdf
To reproduce
Create a cli.App{Usage: ""}
or cli.App{}
struct and launch it with --help
.
Observed behavior
It's not possible to remove the "A new cli application"
string from the help.
Setting Usage
to " "
also leaves the -
.
The only way I've found is to entirely override cli.AppHelpTemplate
or set Usage: "\b\b "
.
Expected behavior
I would like to be able to set Usage
to ""
without it being overridden, or at least be able to customize helpNameTemplate
to be able to remove the part that uses Usage
.
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.22.2 darwin/arm64
Run go env
and paste its output here
GO111MODULE='auto'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/redacted/Library/Caches/go-build'
GOENV='/Users/redacted/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/redacted/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/redacted/go'
GOROOT='/Users/redacted/sdk/go1.22.2'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/redacted/sdk/go1.22.2/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/redacted/cli_path/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/tp/x23ymr696x1fyzfy7rq7fr740000gp/T/go-build457189288=/tmp/go-build -gno-record-gcc-switches -fno-common'
@Amaury-Behague You can set a custom template and override whatever you want in the help text. It is not very user friendly but anyone with a knowledge of go templating should be able to handle it. At this point v2 is in maint mode so we cannot make any changes to the current behavior. If you have an ideas we can incorporate them into v3.