-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
flag: single hyphen for flags (-) should be two hyphens (--) in default help/usage CLI output #47114
Comments
Thanks for the issue, but I'm not sure I see what the source of confusion is. Both forms of flag are accepted (both - and -- prefixes), so I don't think it matters much which is shown by default. Since #45484 asks for exactly the same thing and was closed, I'm going to close this as well. Also note that the |
Well… what matters to me personally is at least consistency, i.e. you should show the same thing always. (But not the one thing in the header and later one the |
Caddy has chosen to write out the flags using two hyphens in the prose section but it's using
That is, Caddy is the source of the inconsistency here. Either Caddy should use the
Go's |
Perhaps you can point them to https://pkg.go.dev/rsc.io/getopt. It should play well with the flag package. |
This is an error in Caddy, which uses your standard library for CLI arguments/flags. And as such, I was told to report this here. 🙃
What version of Go are you using (
go version
)?No idea.
Does this issue reproduce with the latest release?
N/A
What operating system and processor architecture are you using (
go env
)?x64_x86
Linux, Fedora Workstation 34
It's Caddy I'm using that uses your standard library here:
Caddy v2.4.3 h1:Y1FaV2N4WO3rBqxSYA8UZsZTQdN+PwcoOcAiZTM8C0I=
What did you do?
Consider this command:
Or this horrible typo I made:
What did you expect to see?
It is a very common pattern to use one hyphen for single-letter (short parameters) and two for longer arguments,
See e.g.
https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html
various Stackexchange questions (on literally any platform of them 😜 )
https://en.wikipedia.org/wiki/Command-line_interface#Option_conventions_in_Unix-like_systems
As such, I'd propose to always use
--the-two-hypens
when referring to a flag in the help output.What did you see instead?
In the short summary you are writing
--config
e.g., but in the full flag (usually also called parameter, but that is irrelevant IMHO) list below, you list it as-config
, i.e. a single hyphen. Even when your software can handle both, it is somewhat inconsistent and confusing IMHO.Adopted/copied from downstream caddyserver/caddy#4240
The issue seems to lie here, e.g.:
go/src/flag/flag.go
Line 571 in 2701515
go/src/flag/flag.go
Line 963 in 2701515
I.e. there you use the “wrong” number of hyphens.
The text was updated successfully, but these errors were encountered: