Use cobra Example field
This commit is contained in:
parent
4d182c4314
commit
51353c79d6
2 changed files with 4 additions and 6 deletions
|
|
@ -79,8 +79,8 @@ func rootHelpFunc(command *cobra.Command, args []string) {
|
|||
if command.HasLocalFlags() {
|
||||
helpEntries = append(helpEntries, helpEntry{"FLAGS", strings.TrimRight(command.LocalFlags().FlagUsages(), "\n")})
|
||||
}
|
||||
if _, ok := command.Annotations["help:examples"]; ok {
|
||||
helpEntries = append(helpEntries, helpEntry{"EXAMPLES", command.Annotations["help:examples"]})
|
||||
if command.Example != "" {
|
||||
helpEntries = append(helpEntries, helpEntry{"EXAMPLES", command.Example})
|
||||
}
|
||||
if _, ok := command.Annotations["help:learnmore"]; ok {
|
||||
helpEntries = append(helpEntries, helpEntry{"LEARN MORE", command.Annotations["help:learnmore"]})
|
||||
|
|
|
|||
|
|
@ -93,12 +93,10 @@ var RootCmd = &cobra.Command{
|
|||
|
||||
SilenceErrors: true,
|
||||
SilenceUsage: true,
|
||||
|
||||
Annotations: map[string]string{
|
||||
"help:examples": `
|
||||
$ gh issue create
|
||||
Example: `$ gh issue create
|
||||
$ gh repo clone
|
||||
$ gh pr checkout 321`,
|
||||
Annotations: map[string]string{
|
||||
"help:learnmore": `
|
||||
Use "gh <command> <subcommand> --help" for more information about a command.
|
||||
Read the manual at <http://cli.github.com/manual>`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue