From 5b9e64b4854535f6b2f307658bf28deb0a36f07d Mon Sep 17 00:00:00 2001 From: AliabbasMerchant Date: Tue, 26 May 2020 08:00:51 +0530 Subject: [PATCH 1/5] Fix incorrect docs in Issue&PR create --- command/issue.go | 8 ++++---- command/pr_create.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/command/issue.go b/command/issue.go index 3d3f01708..48fcbc453 100644 --- a/command/issue.go +++ b/command/issue.go @@ -29,14 +29,14 @@ func init() { issueCreateCmd.Flags().StringP("body", "b", "", "Supply a body. Will prompt for one otherwise.") issueCreateCmd.Flags().BoolP("web", "w", false, "Open the browser to create an issue") - issueCreateCmd.Flags().StringSliceP("assignee", "a", nil, "Assign a person by their `login`") - issueCreateCmd.Flags().StringSliceP("label", "l", nil, "Add a label by `name`") - issueCreateCmd.Flags().StringSliceP("project", "p", nil, "Add the issue to a project by `name`") + issueCreateCmd.Flags().StringSliceP("assignee", "a", nil, "Assign people by their `login`") + issueCreateCmd.Flags().StringSliceP("label", "l", nil, "Add labels by `name`") + issueCreateCmd.Flags().StringSliceP("project", "p", nil, "Add the issue to projects by `name`") issueCreateCmd.Flags().StringP("milestone", "m", "", "Add the issue to a milestone by `name`") issueCmd.AddCommand(issueListCmd) issueListCmd.Flags().StringP("assignee", "a", "", "Filter by assignee") - issueListCmd.Flags().StringSliceP("label", "l", nil, "Filter by label") + issueListCmd.Flags().StringSliceP("label", "l", nil, "Filter by labels") issueListCmd.Flags().StringP("state", "s", "open", "Filter by state: {open|closed|all}") issueListCmd.Flags().IntP("limit", "L", 30, "Maximum number of issues to fetch") issueListCmd.Flags().StringP("author", "A", "", "Filter by author") diff --git a/command/pr_create.go b/command/pr_create.go index 96dc08791..be8ca6079 100644 --- a/command/pr_create.go +++ b/command/pr_create.go @@ -423,9 +423,9 @@ func init() { prCreateCmd.Flags().BoolP("web", "w", false, "Open the web browser to create a pull request") prCreateCmd.Flags().BoolP("fill", "f", false, "Do not prompt for title/body and just use commit info") - prCreateCmd.Flags().StringSliceP("reviewer", "r", nil, "Request a review from someone by their `login`") - prCreateCmd.Flags().StringSliceP("assignee", "a", nil, "Assign a person by their `login`") - prCreateCmd.Flags().StringSliceP("label", "l", nil, "Add a label by `name`") - prCreateCmd.Flags().StringSliceP("project", "p", nil, "Add the pull request to a project by `name`") + prCreateCmd.Flags().StringSliceP("reviewer", "r", nil, "Request reviews from people by their `login`") + prCreateCmd.Flags().StringSliceP("assignee", "a", nil, "Assign people by their `login`") + prCreateCmd.Flags().StringSliceP("label", "l", nil, "Add labels by `name`") + prCreateCmd.Flags().StringSliceP("project", "p", nil, "Add the pull request to projects by `name`") prCreateCmd.Flags().StringP("milestone", "m", "", "Add the pull request to a milestone by `name`") } From a77556237985871b2effa6bae23cc7b25b32eb6c Mon Sep 17 00:00:00 2001 From: AliabbasMerchant Date: Tue, 9 Jun 2020 23:42:24 +0530 Subject: [PATCH 2/5] Added Examples for Issue and PR Create --- command/issue.go | 11 +++++++++++ command/pr_create.go | 15 +++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/command/issue.go b/command/issue.go index 48fcbc453..4a5c98635 100644 --- a/command/issue.go +++ b/command/issue.go @@ -61,6 +61,17 @@ var issueCreateCmd = &cobra.Command{ Use: "create", Short: "Create a new issue", RunE: issueCreate, + Long: `Create a new issue in a repository + +Examples: + $ gh issue create + $ gh issue create -t "Issue With Title And Body" -b "This is the issue body" + $ gh issue create -t OpenAWebBrowserToCreateThisIssue --web + $ gh issue create -t IssueWithLabels -b IssueBody -l label1,label2 + $ gh issue create -t IssueWithAssignees -b IssueBody -a user1Login,user2Login + $ gh issue create -t IssueWithProjects -b IssueBody -p cli/1,cli/2 + $ gh issue create -t IssueWithMilestone -b IssueBody -m someMilestone +`, } var issueListCmd = &cobra.Command{ Use: "list", diff --git a/command/pr_create.go b/command/pr_create.go index be8ca6079..ee6d2a20e 100644 --- a/command/pr_create.go +++ b/command/pr_create.go @@ -409,6 +409,21 @@ var prCreateCmd = &cobra.Command{ Use: "create", Short: "Create a pull request", RunE: prCreate, + Long: `Create a pull request in a repository + +Examples: + $ gh pr create + $ gh pr create --fill + $ gh pr create -t "PR With Title And Body" -b "This is the pull request body" + $ gh pr create -t OpenAWebBrowserToCreateThisPR --web + $ gh pr create -t DraftPR --draft + $ gh pr create -t PRWithBaseBranch -b PRBody -B branchName + $ gh pr create -t PRWithReviewers -b PRBody -r user1Login,user2Login + $ gh pr create -t PRWithLabels -b PRBody -l label1,label2 + $ gh pr create -t PRWithProjects -b PRBody -p cli/1,cli/2 + $ gh pr create -t PRWithAssignees -b PRBody -a user1Login,user2Login + $ gh pr create -t PRWithMilestone -b PRBody -m someMilestone +`, } func init() { From 4749e91c53cd5d3321bd9b31be9422d5c700543c Mon Sep 17 00:00:00 2001 From: AliabbasMerchant Date: Wed, 10 Jun 2020 09:55:19 +0530 Subject: [PATCH 3/5] Use cobra Example field for issue & PR create examples --- command/issue.go | 17 +++++++---------- command/pr_create.go | 25 +++++++++++-------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/command/issue.go b/command/issue.go index 4a5c98635..3b7b9e9c9 100644 --- a/command/issue.go +++ b/command/issue.go @@ -61,16 +61,13 @@ var issueCreateCmd = &cobra.Command{ Use: "create", Short: "Create a new issue", RunE: issueCreate, - Long: `Create a new issue in a repository - -Examples: - $ gh issue create - $ gh issue create -t "Issue With Title And Body" -b "This is the issue body" - $ gh issue create -t OpenAWebBrowserToCreateThisIssue --web - $ gh issue create -t IssueWithLabels -b IssueBody -l label1,label2 - $ gh issue create -t IssueWithAssignees -b IssueBody -a user1Login,user2Login - $ gh issue create -t IssueWithProjects -b IssueBody -p cli/1,cli/2 - $ gh issue create -t IssueWithMilestone -b IssueBody -m someMilestone + Example: `$ gh issue create +$ gh issue create -t "Issue With Title And Body" -b "This is the issue body" +$ gh issue create -t OpenAWebBrowserToCreateThisIssue --web +$ gh issue create -t IssueWithLabels -b IssueBody -l label1,label2 +$ gh issue create -t IssueWithAssignees -b IssueBody -a user1Login,user2Login +$ gh issue create -t IssueWithProjects -b IssueBody -p cli/1,cli/2 +$ gh issue create -t IssueWithMilestone -b IssueBody -m someMilestone `, } var issueListCmd = &cobra.Command{ diff --git a/command/pr_create.go b/command/pr_create.go index ee6d2a20e..e0fc3ca4e 100644 --- a/command/pr_create.go +++ b/command/pr_create.go @@ -409,20 +409,17 @@ var prCreateCmd = &cobra.Command{ Use: "create", Short: "Create a pull request", RunE: prCreate, - Long: `Create a pull request in a repository - -Examples: - $ gh pr create - $ gh pr create --fill - $ gh pr create -t "PR With Title And Body" -b "This is the pull request body" - $ gh pr create -t OpenAWebBrowserToCreateThisPR --web - $ gh pr create -t DraftPR --draft - $ gh pr create -t PRWithBaseBranch -b PRBody -B branchName - $ gh pr create -t PRWithReviewers -b PRBody -r user1Login,user2Login - $ gh pr create -t PRWithLabels -b PRBody -l label1,label2 - $ gh pr create -t PRWithProjects -b PRBody -p cli/1,cli/2 - $ gh pr create -t PRWithAssignees -b PRBody -a user1Login,user2Login - $ gh pr create -t PRWithMilestone -b PRBody -m someMilestone + Example: `$ gh pr create +$ gh pr create --fill +$ gh pr create -t "PR With Title And Body" -b "This is the pull request body" +$ gh pr create -t OpenAWebBrowserToCreateThisPR --web +$ gh pr create -t DraftPR --draft +$ gh pr create -t PRWithBaseBranch -b PRBody -B branchName +$ gh pr create -t PRWithReviewers -b PRBody -r user1Login,user2Login +$ gh pr create -t PRWithLabels -b PRBody -l label1,label2 +$ gh pr create -t PRWithProjects -b PRBody -p cli/1,cli/2 +$ gh pr create -t PRWithAssignees -b PRBody -a user1Login,user2Login +$ gh pr create -t PRWithMilestone -b PRBody -m someMilestone `, } From 84f3d46338aa32597336d55e0ebcb13e85ea643f Mon Sep 17 00:00:00 2001 From: AliabbasMerchant Date: Sun, 14 Jun 2020 21:53:56 +0530 Subject: [PATCH 4/5] Better example section in issue and pr create --- command/issue.go | 13 ++++++------- command/pr_create.go | 18 +++++++----------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/command/issue.go b/command/issue.go index 3b7b9e9c9..3aa10c89a 100644 --- a/command/issue.go +++ b/command/issue.go @@ -61,13 +61,12 @@ var issueCreateCmd = &cobra.Command{ Use: "create", Short: "Create a new issue", RunE: issueCreate, - Example: `$ gh issue create -$ gh issue create -t "Issue With Title And Body" -b "This is the issue body" -$ gh issue create -t OpenAWebBrowserToCreateThisIssue --web -$ gh issue create -t IssueWithLabels -b IssueBody -l label1,label2 -$ gh issue create -t IssueWithAssignees -b IssueBody -a user1Login,user2Login -$ gh issue create -t IssueWithProjects -b IssueBody -p cli/1,cli/2 -$ gh issue create -t IssueWithMilestone -b IssueBody -m someMilestone + Example: ` + $ gh issue create --title "I found a bug" --body "Nothing works" + $ gh issue create --label label1,label2 + $ gh issue create --label label1 --label label2 + $ gh issue create --assignee user1Login,user2Login + $ gh issue create --project "Our Awesome Project" `, } var issueListCmd = &cobra.Command{ diff --git a/command/pr_create.go b/command/pr_create.go index e0fc3ca4e..0d0089b57 100644 --- a/command/pr_create.go +++ b/command/pr_create.go @@ -409,17 +409,13 @@ var prCreateCmd = &cobra.Command{ Use: "create", Short: "Create a pull request", RunE: prCreate, - Example: `$ gh pr create -$ gh pr create --fill -$ gh pr create -t "PR With Title And Body" -b "This is the pull request body" -$ gh pr create -t OpenAWebBrowserToCreateThisPR --web -$ gh pr create -t DraftPR --draft -$ gh pr create -t PRWithBaseBranch -b PRBody -B branchName -$ gh pr create -t PRWithReviewers -b PRBody -r user1Login,user2Login -$ gh pr create -t PRWithLabels -b PRBody -l label1,label2 -$ gh pr create -t PRWithProjects -b PRBody -p cli/1,cli/2 -$ gh pr create -t PRWithAssignees -b PRBody -a user1Login,user2Login -$ gh pr create -t PRWithMilestone -b PRBody -m someMilestone + Example: ` + $ gh pr create --title "The bug is fixed" --body "Everything works again" + $ gh pr create --label label1,label2 + $ gh pr create --label label1 --label label2 + $ gh pr create --reviewer user1Login,user2Login + $ gh pr create --project "Our Awesome Project" + $ gh pr create --assignee user1Login,user2Login `, } From 3fea249d70cb4f581a34034f9bc71c150b88b895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 16 Jun 2020 16:38:19 +0200 Subject: [PATCH 5/5] :nail_care: tweak `issue/pr create` examples --- command/issue.go | 12 ++++++------ command/pr_create.go | 15 ++++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/command/issue.go b/command/issue.go index 3aa10c89a..ab12a29ed 100644 --- a/command/issue.go +++ b/command/issue.go @@ -61,13 +61,13 @@ var issueCreateCmd = &cobra.Command{ Use: "create", Short: "Create a new issue", RunE: issueCreate, - Example: ` + Example: heredoc.Doc(` $ gh issue create --title "I found a bug" --body "Nothing works" - $ gh issue create --label label1,label2 - $ gh issue create --label label1 --label label2 - $ gh issue create --assignee user1Login,user2Login - $ gh issue create --project "Our Awesome Project" -`, + $ gh issue create --label "bug,help wanted" + $ gh issue create --label bug --label "help wanted" + $ gh issue create --assignee monalisa,hubot + $ gh issue create --project "Roadmap" + `), } var issueListCmd = &cobra.Command{ Use: "list", diff --git a/command/pr_create.go b/command/pr_create.go index 0d0089b57..0c6a5ff26 100644 --- a/command/pr_create.go +++ b/command/pr_create.go @@ -7,6 +7,7 @@ import ( "strings" "time" + "github.com/MakeNowJust/heredoc" "github.com/cli/cli/api" "github.com/cli/cli/context" "github.com/cli/cli/git" @@ -409,14 +410,14 @@ var prCreateCmd = &cobra.Command{ Use: "create", Short: "Create a pull request", RunE: prCreate, - Example: ` + Example: heredoc.Doc(` $ gh pr create --title "The bug is fixed" --body "Everything works again" - $ gh pr create --label label1,label2 - $ gh pr create --label label1 --label label2 - $ gh pr create --reviewer user1Login,user2Login - $ gh pr create --project "Our Awesome Project" - $ gh pr create --assignee user1Login,user2Login -`, + $ gh issue create --label "bug,help wanted" + $ gh issue create --label bug --label "help wanted" + $ gh pr create --reviewer monalisa,hubot + $ gh pr create --project "Roadmap" + $ gh pr create --base develop + `), } func init() {