commands: add a "deselect" command to deselect a previously selected bug

Michael Muré created

Change summary

commands/deselect.go         | 38 ++++++++++++++++++++++++++++++++
doc/man/git-bug-deselect.1   | 44 ++++++++++++++++++++++++++++++++++++++
doc/man/git-bug.1            |  2 
doc/md/git-bug.md            |  1 
doc/md/git-bug_deselect.md   | 32 +++++++++++++++++++++++++++
misc/bash_completion/git-bug | 21 ++++++++++++++++++
misc/zsh_completion/git-bug  |  8 +++---
7 files changed, 141 insertions(+), 5 deletions(-)

Detailed changes

commands/deselect.go 🔗

@@ -0,0 +1,38 @@
+package commands
+
+import (
+	"github.com/MichaelMure/git-bug/cache"
+	"github.com/MichaelMure/git-bug/commands/select"
+	"github.com/spf13/cobra"
+)
+
+func runDeselect(cmd *cobra.Command, args []string) error {
+	backend, err := cache.NewRepoCache(repo)
+	if err != nil {
+		return err
+	}
+	defer backend.Close()
+
+	err = _select.Clear(backend)
+	if err != nil {
+		return err
+	}
+
+	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
+`,
+	RunE: runDeselect,
+}
+
+func init() {
+	RootCmd.AddCommand(deselectCmd)
+	deselectCmd.Flags().SortFlags = false
+}

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

@@ -0,0 +1,44 @@
+.TH "GIT-BUG" "1" "Sep 2018" "Generated from git-bug's source code" "" 
+.nh
+.ad l
+
+
+.SH NAME
+.PP
+git\-bug\-deselect \- Clear the implicitly selected bug
+
+
+.SH SYNOPSIS
+.PP
+\fBgit\-bug deselect [flags]\fP
+
+
+.SH DESCRIPTION
+.PP
+Clear the implicitly selected bug
+
+
+.SH OPTIONS
+.PP
+\fB\-h\fP, \fB\-\-help\fP[=false]
+    help for deselect
+
+
+.SH EXAMPLE
+.PP
+.RS
+
+.nf
+git bug select 2f15
+git bug comment
+git bug status
+git bug deselect
+
+
+.fi
+.RE
+
+
+.SH SEE ALSO
+.PP
+\fBgit\-bug(1)\fP

doc/man/git-bug.1 🔗

@@ -29,4 +29,4 @@ It use the same internal storage so it doesn't pollute your project. As you woul
 
 .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\-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\-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\-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\-ls\-label(1)\fP, \fBgit\-bug\-pull(1)\fP, \fBgit\-bug\-push(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\-webui(1)\fP

doc/md/git-bug.md 🔗

@@ -24,6 +24,7 @@ git-bug [flags]
 * [git-bug bridge](git-bug_bridge.md)	 - Configure and use bridges to other bug trackers
 * [git-bug commands](git-bug_commands.md)	 - Display available commands
 * [git-bug comment](git-bug_comment.md)	 - Display or add comments
+* [git-bug deselect](git-bug_deselect.md)	 - Clear the implicitly selected bug
 * [git-bug label](git-bug_label.md)	 - Display, add or remove labels
 * [git-bug ls](git-bug_ls.md)	 - List bugs
 * [git-bug ls-label](git-bug_ls-label.md)	 - List valid labels

doc/md/git-bug_deselect.md 🔗

@@ -0,0 +1,32 @@
+## git-bug deselect
+
+Clear the implicitly selected bug
+
+### Synopsis
+
+Clear the implicitly selected bug
+
+```
+git-bug deselect [flags]
+```
+
+### Examples
+
+```
+git bug select 2f15
+git bug comment
+git bug status
+git bug deselect
+
+```
+
+### Options
+
+```
+  -h, --help   help for deselect
+```
+
+### SEE ALSO
+
+* [git-bug](git-bug.md)	 - A bug tracker embedded in Git
+

misc/bash_completion/git-bug 🔗

@@ -430,6 +430,26 @@ _git-bug_comment()
     noun_aliases=()
 }
 
+_git-bug_deselect()
+{
+    last_command="git-bug_deselect"
+
+    command_aliases=()
+
+    commands=()
+
+    flags=()
+    two_word_flags=()
+    local_nonpersistent_flags=()
+    flags_with_completion=()
+    flags_completion=()
+
+
+    must_have_one_flag=()
+    must_have_one_noun=()
+    noun_aliases=()
+}
+
 _git-bug_label_add()
 {
     last_command="git-bug_label_add"
@@ -790,6 +810,7 @@ _git-bug_root_command()
     commands+=("bridge")
     commands+=("commands")
     commands+=("comment")
+    commands+=("deselect")
     commands+=("label")
     commands+=("ls")
     commands+=("ls-label")

misc/zsh_completion/git-bug 🔗

@@ -8,7 +8,7 @@ case $state in
   level1)
     case $words[1] in
       git-bug)
-        _arguments '1: :(add bridge commands comment label ls ls-label pull push select show status termui title webui)'
+        _arguments '1: :(add bridge commands comment deselect label ls ls-label pull push select show status termui title webui)'
       ;;
       *)
         _arguments '*: :_files'
@@ -17,6 +17,9 @@ case $state in
   ;;
   level2)
     case $words[2] in
+      bridge)
+        _arguments '2: :(configure pull rm)'
+      ;;
       comment)
         _arguments '2: :(add)'
       ;;
@@ -29,9 +32,6 @@ case $state in
       title)
         _arguments '2: :(edit)'
       ;;
-      bridge)
-        _arguments '2: :(configure pull rm)'
-      ;;
       *)
         _arguments '*: :_files'
       ;;