diff --git a/command/help.go b/command/help.go index fe539d929..e7c9a1e02 100644 --- a/command/help.go +++ b/command/help.go @@ -32,7 +32,7 @@ func rootDisplayCommandTypoHelp(command *cobra.Command, args []string) { oldOut := command.OutOrStdout() command.SetOut(errOut) - defer command.SetOut(oldOut) + command.SetOut(oldOut) } } } @@ -65,11 +65,13 @@ func rootHelpFunc(command *cobra.Command, args []string) { Body string } - helpEntries := []helpEntry{ - {"", command.Long}, - {"USAGE", command.Use}, + helpEntries := []helpEntry{} + if command.Long != "" { + helpEntries = append(helpEntries, helpEntry{"", command.Long}) + } else if command.Short != "" { + helpEntries = append(helpEntries, helpEntry{"", command.Short}) } - + helpEntries = append(helpEntries, helpEntry{"USAGE", command.UseLine()}) if len(coreCommands) > 0 { helpEntries = append(helpEntries, helpEntry{"CORE COMMANDS", strings.Join(coreCommands, "\n")}) } @@ -98,11 +100,8 @@ Read the manual at `}) // If there is a title, add indentation to each line in the body fmt.Fprintln(out, utils.Bold(e.Title)) - for _, l := range strings.Split(e.Body, "\n") { + for _, l := range strings.Split(strings.Trim(e.Body, "\n\r"), "\n") { l = strings.Trim(l, " \n\r") - if l == "" { - continue - } fmt.Fprintln(out, " "+l) } } else { diff --git a/command/issue.go b/command/issue.go index 95df9f086..0f947bfc2 100644 --- a/command/issue.go +++ b/command/issue.go @@ -49,7 +49,7 @@ func init() { } var issueCmd = &cobra.Command{ - Use: "issue [flags]", + Use: "issue ", Short: "Create and view issues", Long: `Work with GitHub issues`, Example: `$ gh issue list diff --git a/command/pr.go b/command/pr.go index 622ef7f1c..dce006bf0 100644 --- a/command/pr.go +++ b/command/pr.go @@ -46,7 +46,7 @@ func init() { } var prCmd = &cobra.Command{ - Use: "pr [flags]", + Use: "pr ", Short: "Create, view, and checkout pull requests", Long: `Work with GitHub pull requests`, Example: `$ gh pr checkout 353 @@ -63,7 +63,10 @@ $ gh pr view --web`, var prListCmd = &cobra.Command{ Use: "list", Short: "List and filter pull requests in this repository", - RunE: prList, + Example: `$ gh pr list --limit all +$ gh pr list --state closed +$ gh pr list --label “priority 1” “bug”`, + RunE: prList, } var prStatusCmd = &cobra.Command{ Use: "status", diff --git a/command/repo.go b/command/repo.go index 9601a3df3..5378cac2a 100644 --- a/command/repo.go +++ b/command/repo.go @@ -41,7 +41,7 @@ func init() { } var repoCmd = &cobra.Command{ - Use: "repo [flags]", + Use: "repo ", Short: "Create, clone, fork, and view repositories", Long: `Work with GitHub repositories`, Example: `$ gh repo create @@ -69,9 +69,18 @@ To pass 'git clone' flags, separate them with '--'.`, var repoCreateCmd = &cobra.Command{ Use: "create []", Short: "Create a new repository", - Long: `Create a new GitHub repository. + Long: `Create a new GitHub repository`, + Example: utils.Bold("$ gh repo create") + ` +Will create a repository on your account using the name of your current directory -Use the "ORG/NAME" syntax to create a repository within your organization.`, +` + utils.Bold("$ gh repo create my-project") + ` +Will create a repository on your account using the name 'my-project' + +` + utils.Bold("$ gh repo create cli/my-project") + ` +Will create a repository in the organization 'cli' using the name 'my-project'`, + Annotations: map[string]string{"help:arguments": `A repository can be supplied as an argument in any of the following formats: +- +- by URL, e.g. "https://github.com/OWNER/REPO"`}, RunE: repoCreate, }