Detailed changes
@@ -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,
}
@@ -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,
}
@@ -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,
}
@@ -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,
}
@@ -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,
}
@@ -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
@@ -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,
}
@@ -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,
}
@@ -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,
}
@@ -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,
}
@@ -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,
}
@@ -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,
}
@@ -10,7 +10,7 @@ git\-bug\-comment\-add \- Add a new comment to a bug
.SH SYNOPSIS
.PP
-\fBgit\-bug comment add <id> [flags]\fP
+\fBgit\-bug comment add [<id>] [flags]\fP
.SH DESCRIPTION
@@ -10,7 +10,7 @@ git\-bug\-comment \- Show a bug's comments
.SH SYNOPSIS
.PP
-\fBgit\-bug comment <id> [flags]\fP
+\fBgit\-bug comment [<id>] [flags]\fP
.SH DESCRIPTION
@@ -10,7 +10,7 @@ git\-bug\-label\-add \- Add a label to a bug
.SH SYNOPSIS
.PP
-\fBgit\-bug label add <id> [<label>\&...] [flags]\fP
+\fBgit\-bug label add [<id>] <label>[...] [flags]\fP
.SH DESCRIPTION
@@ -10,7 +10,7 @@ git\-bug\-label\-rm \- Remove a label from a bug
.SH SYNOPSIS
.PP
-\fBgit\-bug label rm <id> [<label>\&...] [flags]\fP
+\fBgit\-bug label rm [<id>] <label>[...] [flags]\fP
.SH DESCRIPTION
@@ -10,7 +10,7 @@ git\-bug\-label \- Display a bug labels
.SH SYNOPSIS
.PP
-\fBgit\-bug label <id> [flags]\fP
+\fBgit\-bug label [<id>] [flags]\fP
.SH DESCRIPTION
@@ -10,7 +10,7 @@ git\-bug\-select \- Select a bug for implicit use in future commands
.SH SYNOPSIS
.PP
-\fBgit\-bug select [<id>] [flags]\fP
+\fBgit\-bug select <id> [flags]\fP
.SH DESCRIPTION
@@ -10,7 +10,7 @@ git\-bug\-show \- Display the details of a bug
.SH SYNOPSIS
.PP
-\fBgit\-bug show <id> [flags]\fP
+\fBgit\-bug show [<id>] [flags]\fP
.SH DESCRIPTION
@@ -10,7 +10,7 @@ git\-bug\-status\-close \- Mark the bug as closed
.SH SYNOPSIS
.PP
-\fBgit\-bug status close <id> [flags]\fP
+\fBgit\-bug status close [<id>] [flags]\fP
.SH DESCRIPTION
@@ -10,7 +10,7 @@ git\-bug\-status\-open \- Mark the bug as open
.SH SYNOPSIS
.PP
-\fBgit\-bug status open <id> [flags]\fP
+\fBgit\-bug status open [<id>] [flags]\fP
.SH DESCRIPTION
@@ -10,7 +10,7 @@ git\-bug\-status \- Show the bug status
.SH SYNOPSIS
.PP
-\fBgit\-bug status <id> [flags]\fP
+\fBgit\-bug status [<id>] [flags]\fP
.SH DESCRIPTION
@@ -10,7 +10,7 @@ git\-bug\-title\-edit \- Edit a bug title
.SH SYNOPSIS
.PP
-\fBgit\-bug title edit <id> [flags]\fP
+\fBgit\-bug title edit [<id>] [flags]\fP
.SH DESCRIPTION
@@ -10,7 +10,7 @@ git\-bug\-title \- Display a bug's title
.SH SYNOPSIS
.PP
-\fBgit\-bug title <id> [flags]\fP
+\fBgit\-bug title [<id>] [flags]\fP
.SH DESCRIPTION
@@ -7,7 +7,7 @@ Show a bug's comments
Show a bug's comments
```
-git-bug comment <id> [flags]
+git-bug comment [<id>] [flags]
```
### Options
@@ -7,7 +7,7 @@ Add a new comment to a bug
Add a new comment to a bug
```
-git-bug comment add <id> [flags]
+git-bug comment add [<id>] [flags]
```
### Options
@@ -7,7 +7,7 @@ Display a bug labels
Display a bug labels
```
-git-bug label <id> [flags]
+git-bug label [<id>] [flags]
```
### Options
@@ -7,7 +7,7 @@ Add a label to a bug
Add a label to a bug
```
-git-bug label add <id> [<label>...] [flags]
+git-bug label add [<id>] <label>[...] [flags]
```
### Options
@@ -7,7 +7,7 @@ Remove a label from a bug
Remove a label from a bug
```
-git-bug label rm <id> [<label>...] [flags]
+git-bug label rm [<id>] <label>[...] [flags]
```
### Options
@@ -7,7 +7,7 @@ Select a bug for implicit use in future commands
Select a bug for implicit use in future commands
```
-git-bug select [<id>] [flags]
+git-bug select <id> [flags]
```
### Examples
@@ -7,7 +7,7 @@ Display the details of a bug
Display the details of a bug
```
-git-bug show <id> [flags]
+git-bug show [<id>] [flags]
```
### Options
@@ -7,7 +7,7 @@ Show the bug status
Show the bug status
```
-git-bug status <id> [flags]
+git-bug status [<id>] [flags]
```
### Options
@@ -7,7 +7,7 @@ Mark the bug as closed
Mark the bug as closed
```
-git-bug status close <id> [flags]
+git-bug status close [<id>] [flags]
```
### Options
@@ -7,7 +7,7 @@ Mark the bug as open
Mark the bug as open
```
-git-bug status open <id> [flags]
+git-bug status open [<id>] [flags]
```
### Options
@@ -7,7 +7,7 @@ Display a bug's title
Display a bug's title
```
-git-bug title <id> [flags]
+git-bug title [<id>] [flags]
```
### Options
@@ -7,7 +7,7 @@ Edit a bug title
Edit a bug title
```
-git-bug title edit <id> [flags]
+git-bug title edit [<id>] [flags]
```
### Options