diff --git a/command/help.go b/command/help.go index d57763133..b44444b2b 100644 --- a/command/help.go +++ b/command/help.go @@ -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"]}) diff --git a/command/root.go b/command/root.go index ee1a94143..2bda468d0 100644 --- a/command/root.go +++ b/command/root.go @@ -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 --help" for more information about a command. Read the manual at `,