The Wayback Machine - https://web.archive.org/web/20201128052412/https://github.com/dotnet/command-line-api/issues/978
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

Open
NextTurn opened this issue Jul 17, 2020 · 6 comments
Open

Hide subcommand argument #978

NextTurn opened this issue Jul 17, 2020 · 6 comments

Comments

@NextTurn
Copy link
Contributor

@NextTurn NextTurn 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

@jonsequitur jonsequitur commented Jul 17, 2020

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

@NextTurn
Copy link
Contributor Author

@NextTurn NextTurn 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

@StevenRasmussen StevenRasmussen commented Aug 14, 2020

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

@StevenRasmussen StevenRasmussen commented Aug 14, 2020

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

@jonsequitur jonsequitur commented Aug 14, 2020

@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

@StevenRasmussen StevenRasmussen commented Aug 17, 2020

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

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.