diff options
Diffstat (limited to 'commands')
-rw-r--r-- | commands/comment.go | 18 | ||||
-rw-r--r-- | commands/comment_add.go | 18 | ||||
-rw-r--r-- | commands/label add.go | 15 | ||||
-rw-r--r-- | commands/label rm.go | 15 | ||||
-rw-r--r-- | commands/label.go | 16 | ||||
-rw-r--r-- | commands/select.go | 2 | ||||
-rw-r--r-- | commands/show.go | 15 | ||||
-rw-r--r-- | commands/status.go | 18 | ||||
-rw-r--r-- | commands/status_close.go | 17 | ||||
-rw-r--r-- | commands/status_open.go | 17 | ||||
-rw-r--r-- | commands/title.go | 18 | ||||
-rw-r--r-- | commands/title_edit.go | 18 |
12 files changed, 36 insertions, 151 deletions
diff --git a/commands/comment.go b/commands/comment.go index 46267979..9169d7d7 100644 --- a/commands/comment.go +++ b/commands/comment.go @@ -1,36 +1,24 @@ package commands import ( - "errors" "fmt" "github.com/MichaelMure/git-bug/bug" "github.com/MichaelMure/git-bug/cache" + "github.com/MichaelMure/git-bug/commands/select" "github.com/MichaelMure/git-bug/util/colors" "github.com/MichaelMure/git-bug/util/text" "github.com/spf13/cobra" ) func runComment(cmd *cobra.Command, args []string) error { - var err error - - if len(args) > 1 { - return errors.New("Only one bug id is supported") - } - - if len(args) == 0 { - return errors.New("You must provide a bug id") - } - backend, err := cache.NewRepoCache(repo) if err != nil { return err } defer backend.Close() - prefix := args[0] - - b, err := backend.ResolveBugPrefix(prefix) + b, args, err := _select.ResolveBug(backend, args) if err != nil { return err } @@ -55,7 +43,7 @@ func commentsTextOutput(comments []bug.Comment) { } var commentCmd = &cobra.Command{ - Use: "comment <id>", + Use: "comment [<id>]", Short: "Show a bug's comments", RunE: runComment, } diff --git a/commands/comment_add.go b/commands/comment_add.go index 46d0c8b8..c80e9ec5 100644 --- a/commands/comment_add.go +++ b/commands/comment_add.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/MichaelMure/git-bug/cache" + "github.com/MichaelMure/git-bug/commands/select" "github.com/MichaelMure/git-bug/input" - "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -15,24 +15,12 @@ var ( ) func runCommentAdd(cmd *cobra.Command, args []string) error { - var err error - - if len(args) > 1 { - return errors.New("Only one bug id is supported") - } - - if len(args) == 0 { - return errors.New("You must provide a bug id") - } - backend, err := cache.NewRepoCache(repo) if err != nil { return err } defer backend.Close() - prefix := args[0] - if commentAddMessageFile != "" && commentAddMessage == "" { commentAddMessage, err = input.FromFile(commentAddMessageFile) if err != nil { @@ -51,7 +39,7 @@ func runCommentAdd(cmd *cobra.Command, args []string) error { } } - b, err := backend.ResolveBugPrefix(prefix) + b, args, err := _select.ResolveBug(backend, args) if err != nil { return err } @@ -65,7 +53,7 @@ func runCommentAdd(cmd *cobra.Command, args []string) error { } var commentAddCmd = &cobra.Command{ - Use: "add <id>", + Use: "add [<id>]", Short: "Add a new comment to a bug", RunE: runCommentAdd, } diff --git a/commands/label add.go b/commands/label add.go index fccbfaa3..68811dec 100644 --- a/commands/label add.go +++ b/commands/label add.go @@ -1,33 +1,26 @@ package commands import ( - "errors" "fmt" "github.com/MichaelMure/git-bug/cache" + "github.com/MichaelMure/git-bug/commands/select" "github.com/spf13/cobra" ) func runLabelAdd(cmd *cobra.Command, args []string) error { - if len(args) == 0 { - return errors.New("You must provide a bug id") - } - backend, err := cache.NewRepoCache(repo) if err != nil { return err } defer backend.Close() - prefix := args[0] - add := args[1:] - - b, err := backend.ResolveBugPrefix(prefix) + b, args, err := _select.ResolveBug(backend, args) if err != nil { return err } - changes, err := b.ChangeLabels(add, nil) + changes, err := b.ChangeLabels(args, nil) for _, change := range changes { fmt.Println(change) @@ -41,7 +34,7 @@ func runLabelAdd(cmd *cobra.Command, args []string) error { } var labelAddCmd = &cobra.Command{ - Use: "add <id> [<label>...]", + Use: "add [<id>] <label>[...]", Short: "Add a label to a bug", RunE: runLabelAdd, } diff --git a/commands/label rm.go b/commands/label rm.go index 9908094c..8ad89593 100644 --- a/commands/label rm.go +++ b/commands/label rm.go @@ -1,33 +1,26 @@ package commands import ( - "errors" "fmt" "github.com/MichaelMure/git-bug/cache" + "github.com/MichaelMure/git-bug/commands/select" "github.com/spf13/cobra" ) func runLabelRm(cmd *cobra.Command, args []string) error { - if len(args) == 0 { - return errors.New("You must provide a bug id") - } - backend, err := cache.NewRepoCache(repo) if err != nil { return err } defer backend.Close() - prefix := args[0] - remove := args[1:] - - b, err := backend.ResolveBugPrefix(prefix) + b, args, err := _select.ResolveBug(backend, args) if err != nil { return err } - changes, err := b.ChangeLabels(nil, remove) + changes, err := b.ChangeLabels(nil, args) for _, change := range changes { fmt.Println(change) @@ -41,7 +34,7 @@ func runLabelRm(cmd *cobra.Command, args []string) error { } var labelRmCmd = &cobra.Command{ - Use: "rm <id> [<label>...]", + Use: "rm [<id>] <label>[...]", Short: "Remove a label from a bug", RunE: runLabelRm, } diff --git a/commands/label.go b/commands/label.go index c693f82c..d41b6dfb 100644 --- a/commands/label.go +++ b/commands/label.go @@ -1,31 +1,21 @@ package commands import ( - "errors" "fmt" "github.com/MichaelMure/git-bug/cache" + "github.com/MichaelMure/git-bug/commands/select" "github.com/spf13/cobra" ) func runLabel(cmd *cobra.Command, args []string) error { - if len(args) > 1 { - return errors.New("Only one bug id is supported") - } - - if len(args) == 0 { - return errors.New("You must provide a bug id") - } - backend, err := cache.NewRepoCache(repo) if err != nil { return err } defer backend.Close() - prefix := args[0] - - b, err := backend.ResolveBugPrefix(prefix) + b, args, err := _select.ResolveBug(backend, args) if err != nil { return err } @@ -40,7 +30,7 @@ func runLabel(cmd *cobra.Command, args []string) error { } var labelCmd = &cobra.Command{ - Use: "label <id>", + Use: "label [<id>]", Short: "Display a bug labels", RunE: runLabel, } diff --git a/commands/select.go b/commands/select.go index c810b85a..2cbb0b2e 100644 --- a/commands/select.go +++ b/commands/select.go @@ -35,7 +35,7 @@ func runSelect(cmd *cobra.Command, args []string) error { } var selectCmd = &cobra.Command{ - Use: "select [<id>]", + Use: "select <id>", Short: "Select a bug for implicit use in future commands", Example: `git bug select 2f15 git bug comment diff --git a/commands/show.go b/commands/show.go index d4d1bb54..b1b7b432 100644 --- a/commands/show.go +++ b/commands/show.go @@ -6,28 +6,19 @@ import ( "strings" "github.com/MichaelMure/git-bug/cache" + "github.com/MichaelMure/git-bug/commands/select" "github.com/MichaelMure/git-bug/util/colors" "github.com/spf13/cobra" ) func runShowBug(cmd *cobra.Command, args []string) error { - if len(args) > 1 { - return errors.New("Only showing one bug at a time is supported") - } - - if len(args) == 0 { - return errors.New("You must provide a bug id") - } - backend, err := cache.NewRepoCache(repo) if err != nil { return err } defer backend.Close() - prefix := args[0] - - b, err := backend.ResolveBugPrefix(prefix) + b, args, err := _select.ResolveBug(backend, args) if err != nil { return err } @@ -82,7 +73,7 @@ func runShowBug(cmd *cobra.Command, args []string) error { } var showCmd = &cobra.Command{ - Use: "show <id>", + Use: "show [<id>]", Short: "Display the details of a bug", RunE: runShowBug, } diff --git a/commands/status.go b/commands/status.go index 29646b6e..02ddc481 100644 --- a/commands/status.go +++ b/commands/status.go @@ -4,30 +4,18 @@ import ( "fmt" "github.com/MichaelMure/git-bug/cache" - "github.com/pkg/errors" + "github.com/MichaelMure/git-bug/commands/select" "github.com/spf13/cobra" ) func runStatus(cmd *cobra.Command, args []string) error { - var err error - - if len(args) > 1 { - return errors.New("Only one bug id is supported") - } - - if len(args) == 0 { - return errors.New("You must provide a bug id") - } - backend, err := cache.NewRepoCache(repo) if err != nil { return err } defer backend.Close() - prefix := args[0] - - b, err := backend.ResolveBugPrefix(prefix) + b, args, err := _select.ResolveBug(backend, args) if err != nil { return err } @@ -40,7 +28,7 @@ func runStatus(cmd *cobra.Command, args []string) error { } var statusCmd = &cobra.Command{ - Use: "status <id>", + Use: "status [<id>]", Short: "Show the bug status", RunE: runStatus, } diff --git a/commands/status_close.go b/commands/status_close.go index 55e47c22..de8b990c 100644 --- a/commands/status_close.go +++ b/commands/status_close.go @@ -1,30 +1,19 @@ package commands import ( - "errors" - "github.com/MichaelMure/git-bug/cache" + "github.com/MichaelMure/git-bug/commands/select" "github.com/spf13/cobra" ) func runStatusClose(cmd *cobra.Command, args []string) error { - if len(args) > 1 { - return errors.New("Only closing one bug at a time is supported") - } - - if len(args) == 0 { - return errors.New("You must provide a bug id") - } - backend, err := cache.NewRepoCache(repo) if err != nil { return err } defer backend.Close() - prefix := args[0] - - b, err := backend.ResolveBugPrefix(prefix) + b, args, err := _select.ResolveBug(backend, args) if err != nil { return err } @@ -38,7 +27,7 @@ func runStatusClose(cmd *cobra.Command, args []string) error { } var closeCmd = &cobra.Command{ - Use: "close <id>", + Use: "close [<id>]", Short: "Mark the bug as closed", RunE: runStatusClose, } diff --git a/commands/status_open.go b/commands/status_open.go index 15108ddf..6b94b9cb 100644 --- a/commands/status_open.go +++ b/commands/status_open.go @@ -1,30 +1,19 @@ package commands import ( - "errors" - "github.com/MichaelMure/git-bug/cache" + "github.com/MichaelMure/git-bug/commands/select" "github.com/spf13/cobra" ) func runStatusOpen(cmd *cobra.Command, args []string) error { - if len(args) > 1 { - return errors.New("Only opening one bug at a time is supported") - } - - if len(args) == 0 { - return errors.New("You must provide a bug id") - } - backend, err := cache.NewRepoCache(repo) if err != nil { return err } defer backend.Close() - prefix := args[0] - - b, err := backend.ResolveBugPrefix(prefix) + b, args, err := _select.ResolveBug(backend, args) if err != nil { return err } @@ -38,7 +27,7 @@ func runStatusOpen(cmd *cobra.Command, args []string) error { } var openCmd = &cobra.Command{ - Use: "open <id>", + Use: "open [<id>]", Short: "Mark the bug as open", RunE: runStatusOpen, } diff --git a/commands/title.go b/commands/title.go index 16cfc342..dd5fbfb1 100644 --- a/commands/title.go +++ b/commands/title.go @@ -4,30 +4,18 @@ import ( "fmt" "github.com/MichaelMure/git-bug/cache" - "github.com/pkg/errors" + "github.com/MichaelMure/git-bug/commands/select" "github.com/spf13/cobra" ) func runTitle(cmd *cobra.Command, args []string) error { - var err error - - if len(args) > 1 { - return errors.New("Only one bug id is supported") - } - - if len(args) == 0 { - return errors.New("You must provide a bug id") - } - backend, err := cache.NewRepoCache(repo) if err != nil { return err } defer backend.Close() - prefix := args[0] - - b, err := backend.ResolveBugPrefix(prefix) + b, args, err := _select.ResolveBug(backend, args) if err != nil { return err } @@ -40,7 +28,7 @@ func runTitle(cmd *cobra.Command, args []string) error { } var titleCmd = &cobra.Command{ - Use: "title <id>", + Use: "title [<id>]", Short: "Display a bug's title", RunE: runTitle, } diff --git a/commands/title_edit.go b/commands/title_edit.go index 111c6325..a62daf6c 100644 --- a/commands/title_edit.go +++ b/commands/title_edit.go @@ -1,10 +1,10 @@ package commands import ( - "errors" "fmt" "github.com/MichaelMure/git-bug/cache" + "github.com/MichaelMure/git-bug/commands/select" "github.com/MichaelMure/git-bug/input" "github.com/spf13/cobra" ) @@ -14,25 +14,13 @@ var ( ) func runTitleEdit(cmd *cobra.Command, args []string) error { - var err error - - if len(args) > 1 { - return errors.New("Only one bug id is supported") - } - - if len(args) == 0 { - return errors.New("You must provide a bug id") - } - backend, err := cache.NewRepoCache(repo) if err != nil { return err } defer backend.Close() - prefix := args[0] - - b, err := backend.ResolveBugPrefix(prefix) + b, args, err := _select.ResolveBug(backend, args) if err != nil { return err } @@ -59,7 +47,7 @@ func runTitleEdit(cmd *cobra.Command, args []string) error { } var titleEditCmd = &cobra.Command{ - Use: "edit <id>", + Use: "edit [<id>]", Short: "Edit a bug title", RunE: runTitleEdit, } |