aboutsummaryrefslogtreecommitdiffstats
path: root/commands/deselect.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/deselect.go')
-rw-r--r--commands/deselect.go44
1 files changed, 24 insertions, 20 deletions
diff --git a/commands/deselect.go b/commands/deselect.go
index f92c81fd..22a5f55d 100644
--- a/commands/deselect.go
+++ b/commands/deselect.go
@@ -1,14 +1,35 @@
package commands
import (
+ "github.com/spf13/cobra"
+
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/commands/select"
"github.com/MichaelMure/git-bug/util/interrupt"
- "github.com/spf13/cobra"
)
-func runDeselect(cmd *cobra.Command, args []string) error {
- backend, err := cache.NewRepoCache(repo)
+func newDeselectCommand() *cobra.Command {
+ env := newEnv()
+
+ cmd := &cobra.Command{
+ Use: "deselect",
+ Short: "Clear the implicitly selected bug.",
+ Example: `git bug select 2f15
+git bug comment
+git bug status
+git bug deselect
+`,
+ PreRunE: loadRepo(env),
+ RunE: func(cmd *cobra.Command, args []string) error {
+ return runDeselect(env)
+ },
+ }
+
+ return cmd
+}
+
+func runDeselect(env *Env) error {
+ backend, err := cache.NewRepoCache(env.repo)
if err != nil {
return err
}
@@ -22,20 +43,3 @@ func runDeselect(cmd *cobra.Command, args []string) error {
return nil
}
-
-var deselectCmd = &cobra.Command{
- Use: "deselect",
- Short: "Clear the implicitly selected bug.",
- Example: `git bug select 2f15
-git bug comment
-git bug status
-git bug deselect
-`,
- PreRunE: loadRepo,
- RunE: runDeselect,
-}
-
-func init() {
- RootCmd.AddCommand(deselectCmd)
- deselectCmd.Flags().SortFlags = false
-}