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

./tools/ctl --help is not as helpful as it could be #158

Open
msuozzo opened this issue Nov 13, 2024 · 0 comments
Open

./tools/ctl --help is not as helpful as it could be #158

msuozzo opened this issue Nov 13, 2024 · 0 comments

Comments

@msuozzo
Copy link
Member

msuozzo commented Nov 13, 2024

Using golang's built-in flags package interacts poorly with Cobra when providing --help on the command.

We can fix this by using Cobra's native flags (pflags) but the associated refactor isn't a clear positive code-wise. Not a high priority but worth noting this drawback.

Details

go run ./tools/ctl provides the "good" Cobra-based help:

$ go run ./tools/ctl
A debugging tool for OSS-Rebuild

Usage:
  ctl [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  get-results Analyze rebuild results
  help        Help about any command
  list-runs   List runs
  run-bench   Run benchmark
  run-one     Run benchmark
  tui         A terminal UI for the OSS-Rebuild debugging tools

Flags:
  -h, --help   help for ctl

Use "ctl [command] --help" for more information about a command.

...but go run ./tools/ctl --help shows the flat native flag help:

$ go run ./tools/ctl --help
Usage of /tmp/go-build999803442/b001/exe/ctl:
  -api string
        OSS Rebuild API endpoint URI
  -artifact string
        the artifact name
  -bench string
        a path to a benchmark file. if provided, only results from that benchmark will be fetched
  -benchmark-dir string
        a directory with benchmarks to work with
  -clean
        whether to apply normalization heuristics to group similar verdicts
....

Fix

- cmd.Flags().AddGoFlag(flag.Lookup(...))
+ cmd.Flags().StringVar(...)

The usage of the flag values would need to be mediated by either global variables (as flag definitions currently are) or built into cmd-specific data types passed in to the cmd defintions.

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

No branches or pull requests

1 participant