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

Hide subcommand argument #978

Closed
nxtn opened this issue Jul 17, 2020 · 8 comments
Closed

Hide subcommand argument #978

nxtn opened this issue Jul 17, 2020 · 8 comments
Labels
Area-Help enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@nxtn
Copy link
Contributor

nxtn commented Jul 17, 2020

I'm building a CLI similar to dotnet where each subcommand has an optional argument. The top level help message looks like the following:

Commands:
  install <path-to-config>      ...
  uninstall <path-to-config>    ...
  start <path-to-config>        ...
  stop <path-to-config>         ...
  restart <path-to-config>      ...
  status <path-to-config>       ...
  test <path-to-config>         ...

I think this looks a bit messy and confusing - the argument seems to be required (<>) rather than optional ([<>]). Is it possible to hide the argument here?

@jonsequitur
Copy link
Contributor

Would you rather hide it than add the [ ] around it to indicate it's optional? Is there a default value?

@nxtn
Copy link
Contributor Author

nxtn commented Jul 17, 2020

I'd prefer to hide it to simplify the top level help message.

There isn't a default value. Its arity is ZeroOrOne. (null can be considered as the default. I use ZeroOrOne because [default: ] can't be hidden.)

@StevenRasmussen
Copy link

I'm looking for the ability to also hide both arguments and options from commands (either main or sub commands). My use case: I'm building a public CLI that others can use but it will also be used by another application (which I control). There are certain args/options that I only want this other application to use and know about. So when an end user queries the help I don't want those args/options to be output to the command line (mostly because it will add noise and confusion as an end user wouldn't know how these args/options are meant to be used). Thanks

@StevenRasmussen
Copy link

Also, if this is something where you would consider accepting a PR I'd be happy to try and work this out. It seems like it could be as simple as adding an IsHidden property to an arg and option and then simply check this at the time that the help text is written to the output window.

@jonsequitur
Copy link
Contributor

@StevenRasmussen There's an IsHidden property on Symbol (i.e. Command, Option, and Argument). If you set that, is the help output what you're looking for? What changes would you like to see?

We'd absolutely appreciate a PR as long as we agree on the goal.

@StevenRasmussen
Copy link

@jonsequitur - Doh! I totally missed that 🤦‍♂️. Does exactly what I need! Thanks!

@jonsequitur jonsequitur added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed and removed waiting-on-feedback labels Aug 17, 2020
@nxtn
Copy link
Contributor Author

nxtn commented Mar 19, 2021

Was this rejected?

@jonsequitur
Copy link
Contributor

Nope. We're making the help API more flexible via #1229 which will make this kind of fine-grained customization easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Help enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants