aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Passos <rafael@rcpassos.me>2018-10-24 18:36:39 -0300
committerRafael Passos <rafael@rcpassos.me>2018-10-24 18:36:39 -0300
commitf72b18496b508c23cee6fa99d764cfe59208515c (patch)
tree0cc0183f66e315319795a264d47ffab59983e3ad
parent4f4af4584f21f294cb77b4adbd4a2ae054b49be9 (diff)
downloadgit-bug-f72b18496b508c23cee6fa99d764cfe59208515c.tar.gz
moved cleaner function to util/interrupt
-rw-r--r--commands/add.go4
-rw-r--r--commands/bridge.go4
-rw-r--r--commands/bridge_configure.go4
-rw-r--r--commands/bridge_pull.go4
-rw-r--r--commands/bridge_rm.go4
-rw-r--r--commands/comment.go4
-rw-r--r--commands/comment_add.go4
-rw-r--r--commands/deselect.go4
-rw-r--r--commands/label.go4
-rw-r--r--commands/label_add.go4
-rw-r--r--commands/label_rm.go4
-rw-r--r--commands/ls-labels.go4
-rw-r--r--commands/ls.go4
-rw-r--r--commands/pull.go4
-rw-r--r--commands/push.go4
-rw-r--r--commands/select.go4
-rw-r--r--commands/show.go4
-rw-r--r--commands/status.go4
-rw-r--r--commands/status_close.go4
-rw-r--r--commands/status_open.go4
-rw-r--r--commands/termui.go4
-rw-r--r--commands/title.go4
-rw-r--r--commands/title_edit.go4
-rw-r--r--util/interrupt/cleaner.go (renamed from cleaner/cleaner.go)6
24 files changed, 49 insertions, 49 deletions
diff --git a/commands/add.go b/commands/add.go
index e2650406..54ede126 100644
--- a/commands/add.go
+++ b/commands/add.go
@@ -4,8 +4,8 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/input"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -23,7 +23,7 @@ func runAddBug(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
if addMessageFile != "" && addMessage == "" {
addTitle, addMessage, err = input.BugCreateFileInput(addMessageFile)
diff --git a/commands/bridge.go b/commands/bridge.go
index ffba2b9d..a473776d 100644
--- a/commands/bridge.go
+++ b/commands/bridge.go
@@ -5,7 +5,7 @@ import (
"github.com/MichaelMure/git-bug/bridge"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -15,7 +15,7 @@ func runBridge(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
configured, err := bridge.ConfiguredBridges(backend)
if err != nil {
diff --git a/commands/bridge_configure.go b/commands/bridge_configure.go
index c4d41c74..ef499f1f 100644
--- a/commands/bridge_configure.go
+++ b/commands/bridge_configure.go
@@ -9,7 +9,7 @@ import (
"github.com/MichaelMure/git-bug/bridge"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -19,7 +19,7 @@ func runBridgeConfigure(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
target, err := promptTarget()
if err != nil {
diff --git a/commands/bridge_pull.go b/commands/bridge_pull.go
index f7e2acf0..669a6713 100644
--- a/commands/bridge_pull.go
+++ b/commands/bridge_pull.go
@@ -4,7 +4,7 @@ import (
"github.com/MichaelMure/git-bug/bridge"
"github.com/MichaelMure/git-bug/bridge/core"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -14,7 +14,7 @@ func runBridgePull(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
var b *core.Bridge
diff --git a/commands/bridge_rm.go b/commands/bridge_rm.go
index 92f1b3c5..172fc0d8 100644
--- a/commands/bridge_rm.go
+++ b/commands/bridge_rm.go
@@ -3,7 +3,7 @@ package commands
import (
"github.com/MichaelMure/git-bug/bridge"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -13,7 +13,7 @@ func runBridgeRm(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
err = bridge.RemoveBridges(backend, args[0])
if err != nil {
diff --git a/commands/comment.go b/commands/comment.go
index f644a23f..89378da3 100644
--- a/commands/comment.go
+++ b/commands/comment.go
@@ -5,9 +5,9 @@ import (
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/commands/select"
"github.com/MichaelMure/git-bug/util/colors"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/MichaelMure/git-bug/util/text"
"github.com/spf13/cobra"
)
@@ -18,7 +18,7 @@ func runComment(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
b, args, err := _select.ResolveBug(backend, args)
if err != nil {
diff --git a/commands/comment_add.go b/commands/comment_add.go
index 3266e941..58408bc5 100644
--- a/commands/comment_add.go
+++ b/commands/comment_add.go
@@ -4,9 +4,9 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/commands/select"
"github.com/MichaelMure/git-bug/input"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -21,7 +21,7 @@ func runCommentAdd(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
b, args, err := _select.ResolveBug(backend, args)
if err != nil {
diff --git a/commands/deselect.go b/commands/deselect.go
index d04e7bc1..210f158c 100644
--- a/commands/deselect.go
+++ b/commands/deselect.go
@@ -2,8 +2,8 @@ package commands
import (
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/commands/select"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -13,7 +13,7 @@ func runDeselect(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
err = _select.Clear(backend)
if err != nil {
diff --git a/commands/label.go b/commands/label.go
index 75a034f8..58ccc299 100644
--- a/commands/label.go
+++ b/commands/label.go
@@ -4,8 +4,8 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/commands/select"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -15,7 +15,7 @@ func runLabel(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
b, args, err := _select.ResolveBug(backend, args)
if err != nil {
diff --git a/commands/label_add.go b/commands/label_add.go
index 4fe6b327..f04ed7d6 100644
--- a/commands/label_add.go
+++ b/commands/label_add.go
@@ -4,8 +4,8 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/commands/select"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -15,7 +15,7 @@ func runLabelAdd(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
b, args, err := _select.ResolveBug(backend, args)
if err != nil {
diff --git a/commands/label_rm.go b/commands/label_rm.go
index b8cc9620..36051ba1 100644
--- a/commands/label_rm.go
+++ b/commands/label_rm.go
@@ -4,8 +4,8 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/commands/select"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -15,7 +15,7 @@ func runLabelRm(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
b, args, err := _select.ResolveBug(backend, args)
if err != nil {
diff --git a/commands/ls-labels.go b/commands/ls-labels.go
index 525303e0..ef2c95bc 100644
--- a/commands/ls-labels.go
+++ b/commands/ls-labels.go
@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -14,7 +14,7 @@ func runLsLabel(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
labels := backend.ValidLabels()
diff --git a/commands/ls.go b/commands/ls.go
index a25aa582..2f621bc5 100644
--- a/commands/ls.go
+++ b/commands/ls.go
@@ -6,8 +6,8 @@ import (
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/util/colors"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -26,7 +26,7 @@ func runLsBug(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
var query *cache.Query
if len(args) >= 1 {
diff --git a/commands/pull.go b/commands/pull.go
index cfdcd771..67c2a339 100644
--- a/commands/pull.go
+++ b/commands/pull.go
@@ -6,7 +6,7 @@ import (
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -25,7 +25,7 @@ func runPull(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
fmt.Println("Fetching remote ...")
diff --git a/commands/push.go b/commands/push.go
index 599b5557..0477be60 100644
--- a/commands/push.go
+++ b/commands/push.go
@@ -5,7 +5,7 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -24,7 +24,7 @@ func runPush(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
stdout, err := backend.Push(remote)
if err != nil {
diff --git a/commands/select.go b/commands/select.go
index a519d921..cc688354 100644
--- a/commands/select.go
+++ b/commands/select.go
@@ -5,8 +5,8 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/commands/select"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -20,7 +20,7 @@ func runSelect(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
prefix := args[0]
diff --git a/commands/show.go b/commands/show.go
index d6c05d87..86c01a17 100644
--- a/commands/show.go
+++ b/commands/show.go
@@ -6,9 +6,9 @@ import (
"strings"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/commands/select"
"github.com/MichaelMure/git-bug/util/colors"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -18,7 +18,7 @@ func runShowBug(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
b, args, err := _select.ResolveBug(backend, args)
if err != nil {
diff --git a/commands/status.go b/commands/status.go
index bdd6dd4a..7928628a 100644
--- a/commands/status.go
+++ b/commands/status.go
@@ -4,8 +4,8 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/commands/select"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -15,7 +15,7 @@ func runStatus(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
b, args, err := _select.ResolveBug(backend, args)
if err != nil {
diff --git a/commands/status_close.go b/commands/status_close.go
index 823d98b5..2b4f9602 100644
--- a/commands/status_close.go
+++ b/commands/status_close.go
@@ -2,8 +2,8 @@ package commands
import (
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/commands/select"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -13,7 +13,7 @@ func runStatusClose(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
b, args, err := _select.ResolveBug(backend, args)
if err != nil {
diff --git a/commands/status_open.go b/commands/status_open.go
index 0413d2b7..5e3029e2 100644
--- a/commands/status_open.go
+++ b/commands/status_open.go
@@ -2,8 +2,8 @@ package commands
import (
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/commands/select"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -13,7 +13,7 @@ func runStatusOpen(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
b, args, err := _select.ResolveBug(backend, args)
if err != nil {
diff --git a/commands/termui.go b/commands/termui.go
index d3dbc733..4a029d6c 100644
--- a/commands/termui.go
+++ b/commands/termui.go
@@ -2,8 +2,8 @@ package commands
import (
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/termui"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -13,7 +13,7 @@ func runTermUI(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
return termui.Run(backend)
}
diff --git a/commands/title.go b/commands/title.go
index 37db03dd..c9157a70 100644
--- a/commands/title.go
+++ b/commands/title.go
@@ -4,8 +4,8 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/commands/select"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -15,7 +15,7 @@ func runTitle(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
b, args, err := _select.ResolveBug(backend, args)
if err != nil {
diff --git a/commands/title_edit.go b/commands/title_edit.go
index de9a55ab..6bbd1b0a 100644
--- a/commands/title_edit.go
+++ b/commands/title_edit.go
@@ -4,9 +4,9 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/cleaner"
"github.com/MichaelMure/git-bug/commands/select"
"github.com/MichaelMure/git-bug/input"
+ "github.com/MichaelMure/git-bug/util/interrupt"
"github.com/spf13/cobra"
)
@@ -20,7 +20,7 @@ func runTitleEdit(cmd *cobra.Command, args []string) error {
return err
}
defer backend.Close()
- cleaner.Register(backend.Close)
+ interrupt.RegisterCleaner(backend.Close)
b, args, err := _select.ResolveBug(backend, args)
if err != nil {
diff --git a/cleaner/cleaner.go b/util/interrupt/cleaner.go
index 595c9fb0..dfb8e25b 100644
--- a/cleaner/cleaner.go
+++ b/util/interrupt/cleaner.go
@@ -1,4 +1,4 @@
-package cleaner
+package interrupt
import (
"fmt"
@@ -12,8 +12,8 @@ type Cleaner func() error
var cleaners []Cleaner
var inactive bool
-// Register a cleaner function. When a function is registered, the Signal watcher is started in a goroutine.
-func Register(f Cleaner) {
+// RegisterCleaner is responsible for regisreting a cleaner function. When a function is registered, the Signal watcher is started in a goroutine.
+func RegisterCleaner(f Cleaner) {
cleaners = append(cleaners, f)
if !inactive {
inactive = false