moved cleaner function to util/interrupt

Rafael Passos created

Change summary

commands/add.go              | 4 ++--
commands/bridge.go           | 4 ++--
commands/bridge_configure.go | 4 ++--
commands/bridge_pull.go      | 4 ++--
commands/bridge_rm.go        | 4 ++--
commands/comment.go          | 4 ++--
commands/comment_add.go      | 4 ++--
commands/deselect.go         | 4 ++--
commands/label.go            | 4 ++--
commands/label_add.go        | 4 ++--
commands/label_rm.go         | 4 ++--
commands/ls-labels.go        | 4 ++--
commands/ls.go               | 4 ++--
commands/pull.go             | 4 ++--
commands/push.go             | 4 ++--
commands/select.go           | 4 ++--
commands/show.go             | 4 ++--
commands/status.go           | 4 ++--
commands/status_close.go     | 4 ++--
commands/status_open.go      | 4 ++--
commands/termui.go           | 4 ++--
commands/title.go            | 4 ++--
commands/title_edit.go       | 4 ++--
util/interrupt/cleaner.go    | 6 +++---
24 files changed, 49 insertions(+), 49 deletions(-)

Detailed changes

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)

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 {

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 {

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
 

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 {

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 {

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 {

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 {

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 {

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 {

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 {

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()
 

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 {

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 ...")
 

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 {

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]
 

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 {

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 {

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 {

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 {

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)
 }

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 {

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 {

cleaner/cleaner.go → 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