-
Notifications
You must be signed in to change notification settings - Fork 309
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
How to group subcommands #387
Comments
I'm not quite sure the reason why you are using groups in this example here. Why do you want to group subcommands? type Cmd1 struct {
Opt1 string `long:"opt1" description:"first opt" required:"true"`
Opt2 int `long:"opt2" description:"second opt" default:"10"`
}
type Cmd2 struct {
OptA string `long:"optA" description:"opt a" default:":8080"`
OptB string `long:"optB" description:"opt b" default:"debug"`
}
type MainCmd struct {
CmdA Cmd1 `command:"cmd1"`
CmdB Cmd2 `command:"cmd2"`
} Even simpler: type MainCmd struct {
Cmd1 struct {
Opt1 string `long:"opt1" description:"first opt" required:"true"`
Opt2 int `long:"opt2" description:"second opt" default:"10"`
} `command:"cmd1"`
Cmd2 struct {
OptA string `long:"optA" description:"opt a" default:":8080"`
OptB string `long:"optB" description:"opt b" default:"debug"`
} `command:"cmd2"`
} Let me know if this helps. |
Thanks for the help. I tried the suggested approach; however, it did not give me the expected output. The help message I have is :
The example I provided is just a simple piece of workable code to demonstrate my basic need. I think there are many reasons people want to group or categorize subcommands, especially for organizing the help message better. For example, in some system setting related commands, we may want the help message organize the commands as follows:
Hope this can answer your concerns. |
Hello ! |
Hi,
I am trying to group the subcommands using the top-level option "group" in the struct field. But instead of grouping the subcommands, it actually groups the options in the subcommands. Here is my code:
What I am looking for is when I run the main function, it will print the help message with the grouped subcommands like:
However it groups the subcommands' options like:
Any ideas or help? Thanks!
The text was updated successfully, but these errors were encountered: