Merge pull request #885 from MichaelMure/feat-530-make-label-commands-consistent

Steve Moyer created

feat(530): make label commands consistent

Change summary

commands/label.go          |  3 ++-
commands/label_ls.go       | 33 +++++++++++++++++++++++++++++++++
commands/ls-labels.go      | 18 +++++++-----------
doc/man/git-bug-label-ls.1 |  8 ++++----
doc/man/git-bug-label.1    |  2 +-
doc/man/git-bug.1          |  2 +-
doc/md/git-bug.md          |  1 -
doc/md/git-bug_label.md    |  1 +
doc/md/git-bug_label_ls.md |  8 ++++----
9 files changed, 53 insertions(+), 23 deletions(-)

Detailed changes

commands/label.go 🔗

@@ -20,13 +20,14 @@ func newLabelCommand() *cobra.Command {
 	}
 
 	cmd.AddCommand(newLabelAddCommand())
+	cmd.AddCommand(newLabelLsCommand())
 	cmd.AddCommand(newLabelRmCommand())
 
 	return cmd
 }
 
 func runLabel(env *Env, args []string) error {
-	b, args, err := _select.ResolveBug(env.backend, args)
+	b, _, err := _select.ResolveBug(env.backend, args)
 	if err != nil {
 		return err
 	}

commands/label_ls.go 🔗

@@ -0,0 +1,33 @@
+package commands
+
+import (
+	"github.com/spf13/cobra"
+)
+
+func newLabelLsCommand() *cobra.Command {
+	env := newEnv()
+
+	cmd := &cobra.Command{
+		Use:   "ls",
+		Short: "List valid labels.",
+		Long: `List valid labels.
+
+Note: in the future, a proper label policy could be implemented where valid labels are defined in a configuration file. Until that, the default behavior is to return the list of labels already used.`,
+		PreRunE: loadBackend(env),
+		RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
+			return runLabelLs(env)
+		}),
+	}
+
+	return cmd
+}
+
+func runLabelLs(env *Env) error {
+	labels := env.backend.ValidLabels()
+
+	for _, l := range labels {
+		env.out.Println(l)
+	}
+
+	return nil
+}

commands/ls-labels.go 🔗

@@ -15,19 +15,15 @@ func newLsLabelCommand() *cobra.Command {
 Note: in the future, a proper label policy could be implemented where valid labels are defined in a configuration file. Until that, the default behavior is to return the list of labels already used.`,
 		PreRunE: loadBackend(env),
 		RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
-			return runLsLabel(env)
+			return runLabelLs(env)
 		}),
-	}
-
-	return cmd
-}
-
-func runLsLabel(env *Env) error {
-	labels := env.backend.ValidLabels()
+		Deprecated: ` and will be removed in v1.0.
 
-	for _, l := range labels {
-		env.out.Println(l)
+The functionality provided by this command is now provided by
+the following (equivalent) command:
+git-bug label ls
+`,
 	}
 
-	return nil
+	return cmd
 }

doc/man/git-bug-ls-label.1 → doc/man/git-bug-label-ls.1 🔗

@@ -3,12 +3,12 @@
 
 .SH NAME
 .PP
-git-bug-ls-label - List valid labels.
+git-bug-label-ls - List valid labels.
 
 
 .SH SYNOPSIS
 .PP
-\fBgit-bug ls-label [flags]\fP
+\fBgit-bug label ls [flags]\fP
 
 
 .SH DESCRIPTION
@@ -22,9 +22,9 @@ Note: in the future, a proper label policy could be implemented where valid labe
 .SH OPTIONS
 .PP
 \fB-h\fP, \fB--help\fP[=false]
-	help for ls-label
+	help for ls
 
 
 .SH SEE ALSO
 .PP
-\fBgit-bug(1)\fP
+\fBgit-bug-label(1)\fP

doc/man/git-bug-label.1 🔗

@@ -24,4 +24,4 @@ Display, add or remove labels to/from a bug.
 
 .SH SEE ALSO
 .PP
-\fBgit-bug(1)\fP, \fBgit-bug-label-add(1)\fP, \fBgit-bug-label-rm(1)\fP
+\fBgit-bug(1)\fP, \fBgit-bug-label-add(1)\fP, \fBgit-bug-label-ls(1)\fP, \fBgit-bug-label-rm(1)\fP

doc/man/git-bug.1 🔗

@@ -29,4 +29,4 @@ the same git remote you are already using to collaborate with other people.
 
 .SH SEE ALSO
 .PP
-\fBgit-bug-add(1)\fP, \fBgit-bug-bridge(1)\fP, \fBgit-bug-commands(1)\fP, \fBgit-bug-comment(1)\fP, \fBgit-bug-deselect(1)\fP, \fBgit-bug-label(1)\fP, \fBgit-bug-ls(1)\fP, \fBgit-bug-ls-label(1)\fP, \fBgit-bug-pull(1)\fP, \fBgit-bug-push(1)\fP, \fBgit-bug-rm(1)\fP, \fBgit-bug-select(1)\fP, \fBgit-bug-show(1)\fP, \fBgit-bug-status(1)\fP, \fBgit-bug-termui(1)\fP, \fBgit-bug-title(1)\fP, \fBgit-bug-user(1)\fP, \fBgit-bug-version(1)\fP, \fBgit-bug-webui(1)\fP
+\fBgit-bug-add(1)\fP, \fBgit-bug-bridge(1)\fP, \fBgit-bug-commands(1)\fP, \fBgit-bug-comment(1)\fP, \fBgit-bug-deselect(1)\fP, \fBgit-bug-label(1)\fP, \fBgit-bug-ls(1)\fP, \fBgit-bug-pull(1)\fP, \fBgit-bug-push(1)\fP, \fBgit-bug-rm(1)\fP, \fBgit-bug-select(1)\fP, \fBgit-bug-show(1)\fP, \fBgit-bug-status(1)\fP, \fBgit-bug-termui(1)\fP, \fBgit-bug-title(1)\fP, \fBgit-bug-user(1)\fP, \fBgit-bug-version(1)\fP, \fBgit-bug-webui(1)\fP

doc/md/git-bug.md 🔗

@@ -31,7 +31,6 @@ git-bug [flags]
 * [git-bug deselect](git-bug_deselect.md)	 - Clear the implicitly selected bug.
 * [git-bug label](git-bug_label.md)	 - Display, add or remove labels to/from a bug.
 * [git-bug ls](git-bug_ls.md)	 - List bugs.
-* [git-bug ls-label](git-bug_ls-label.md)	 - List valid labels.
 * [git-bug pull](git-bug_pull.md)	 - Pull bugs update from a git remote.
 * [git-bug push](git-bug_push.md)	 - Push bugs update to a git remote.
 * [git-bug rm](git-bug_rm.md)	 - Remove an existing bug.

doc/md/git-bug_label.md 🔗

@@ -16,5 +16,6 @@ git-bug label [ID] [flags]
 
 * [git-bug](git-bug.md)	 - A bug tracker embedded in Git.
 * [git-bug label add](git-bug_label_add.md)	 - Add a label to a bug.
+* [git-bug label ls](git-bug_label_ls.md)	 - List valid labels.
 * [git-bug label rm](git-bug_label_rm.md)	 - Remove a label from a bug.
 

doc/md/git-bug_ls-label.md → doc/md/git-bug_label_ls.md 🔗

@@ -1,4 +1,4 @@
-## git-bug ls-label
+## git-bug label ls
 
 List valid labels.
 
@@ -9,16 +9,16 @@ List valid labels.
 Note: in the future, a proper label policy could be implemented where valid labels are defined in a configuration file. Until that, the default behavior is to return the list of labels already used.
 
 ```
-git-bug ls-label [flags]
+git-bug label ls [flags]
 ```
 
 ### Options
 
 ```
-  -h, --help   help for ls-label
+  -h, --help   help for ls
 ```
 
 ### SEE ALSO
 
-* [git-bug](git-bug.md)	 - A bug tracker embedded in Git.
+* [git-bug label](git-bug_label.md)	 - Display, add or remove labels to/from a bug.