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

Disable placeholder #241

Closed
p3lim opened this issue Mar 23, 2024 · 4 comments · Fixed by #243
Closed

Disable placeholder #241

p3lim opened this issue Mar 23, 2024 · 4 comments · Fixed by #243

Comments

@p3lim
Copy link

p3lim commented Mar 23, 2024

If placeholder is set to an empty string, don't show it.

Example:

package main

import "github.com/alexflint/go-arg"

type args struct {
	Example string `arg:"-e" placeholder:"" help:"foo"`
}

func main() {
	var args args
	arg.MustParse(&args)
}

Expected result:

Usage: arg [--example]

Options:
  --example, -e          foo
  --help, -h             display this help and exit

Actual result:

Usage: arg [--example ]

Options:
  --example , -e         foo
  --help, -h             display this help and exit
@alexflint
Copy link
Owner

Seems reasonable but out of interest why would you put a struct tag with an empty string for the placeholder in the first place?

@p3lim
Copy link
Author

p3lim commented Mar 23, 2024

Better example why I want to hide the placeholders:

Before:

Usage: arg [--config CONFIG] [--output OUTPUT] [--key KEY] [--quiet]

Options:
  --config CONFIG, -c CONFIG
                         help me
  --output OUTPUT, -o OUTPUT
                         help me
  --key KEY, -k KEY      help me
  --quiet, -q            help me
  --help, -h             display this help and exit

After:

Usage: arg [--config ] [--output ] [--key ] [--quiet]

Options:
  --config , -c          help me
  --output , -o          help me
  --key , -k             help me
  --quiet, -q            help me
  --help, -h             display this help and exit

The placeholder just destroys the readability of the help section (in my opinion at least), and this was only a small example.

@p3lim
Copy link
Author

p3lim commented Mar 23, 2024

I could live with them if the options ended up like this though:

Usage: arg [--config CONFIG] [--output OUTPUT] [--key KEY] [--quiet]

Options:
  --config, -c CONFIG   help me
  --output, -o OUTPUT   help me
  --key, -k KEY         help me
  --quiet, -q           help me
  --help, -h            display this help and exit

This seems to be the norm with long and short option variants, which go-arg doesn't follow.

@alexflint
Copy link
Owner

Ah very good point!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants