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

Cobra SetUsageTemplate() overrides the help message #2066

Open
almahfudhi opened this issue Nov 7, 2023 · 1 comment
Open

Cobra SetUsageTemplate() overrides the help message #2066

almahfudhi opened this issue Nov 7, 2023 · 1 comment

Comments

@almahfudhi
Copy link

almahfudhi commented Nov 7, 2023

I have an issue with the way Cobra shows Usage section in Help message. I have rootCmd that has sub-commands and flags. Both can be given at the same time. Cobra shows the Usage section as:

This is a root command
Usage:
    rootCmd [flags]
    rootCmd [command]
    
Available Commands:
    print         print a message
    list            list version
    
Flags:
-h, --help          help message
-v, --verbose     verbose

it might raise confusion as this indicates either flags or commands can be given at a time, which is not helpful.
I want only the Usage section to be modified, and leave the rest of the help message as is.
desired output:

  This is a root command
Usage:
    rootCmd [flags] [command]
    
Available Commands:
    print         print a message
    list            list version
    
Flags:
-h, --help          help message
-v, --verbose     verbose

[flags] and [commands] are in the same line

using SetUsageTemplate completely overrides the help message, hence removing available commands and flags section

@marckhouzam
Copy link
Collaborator

You’ll have to override the default help message to suit your needs

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

2 participants