spf13 / cobra

A Commander for modern Go CLI interactions
https://cobra.dev
Apache License 2.0
38.41k stars 2.86k forks source link

Getting --help to print descriptions for arguments #2170

Open Reikimann opened 4 months ago

Reikimann commented 4 months ago

Hey, I wanted to check the progress on getting --help to print the ValidArgs for a cmd.

Almost every big arg-parser provided this functionality. Some have already written issues for this functionality; the first written is almost 7 years old. (See https://github.com/spf13/cobra/issues/571, https://github.com/spf13/cobra/pull/1210 and https://github.com/spf13/cobra/pull/842

I see that this project is working on adding wonderful features such as internationalization, but it doesn't seem as necessary as being able to provide help from the cmdline to users.

I'm writing a commandline tool with cobra and I need an init-cmd to generate the shell configuration needed for the tool, but I have no way of providing the information to the user regarding which shells are available.

Zoxide, which uses Rust Clap, provides the user with the available shells they can use like this:

Generate shell configuration

Usage:
  zoxide init [OPTIONS] <SHELL>

Arguments:
  <SHELL>  [possible values: bash, elvish, fish, nushell, posix, powershell, xonsh, zsh]