aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-13 12:20:28 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-13 12:20:28 +0200
commitf569e6aacc0690e7b1bebf33a10a8e0d154937df (patch)
treec17ac2201b7abbc6889137d968c8450dc3099f9a /commands
parent8a25c63d6972d9168dcb3599066076bdb84f8790 (diff)
downloadgit-bug-f569e6aacc0690e7b1bebf33a10a8e0d154937df.tar.gz
operations: return a more convenient array of result for label changes
Diffstat (limited to 'commands')
-rw-r--r--commands/label.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/commands/label.go b/commands/label.go
index f5e3a6fc..37013f3f 100644
--- a/commands/label.go
+++ b/commands/label.go
@@ -2,9 +2,10 @@ package commands
import (
"errors"
- "os"
+ "fmt"
"github.com/MichaelMure/git-bug/cache"
+ "github.com/MichaelMure/git-bug/operations"
"github.com/spf13/cobra"
)
@@ -40,7 +41,25 @@ func runLabel(cmd *cobra.Command, args []string) error {
return err
}
- err = b.ChangeLabels(os.Stdout, add, remove)
+ changes, err := b.ChangeLabels(add, remove)
+
+ for _, change := range changes {
+ switch change.Status {
+ case operations.LabelChangeAdded:
+ fmt.Printf("label %s added\n", change.Label)
+ case operations.LabelChangeRemoved:
+ fmt.Printf("label %s removed\n", change.Label)
+ case operations.LabelChangeDuplicateInOp:
+ fmt.Printf("label %s is a duplicate\n", change.Label)
+ case operations.LabelChangeAlreadySet:
+ fmt.Printf("label %s was already set\n", change.Label)
+ case operations.LabelChangeDoesntExist:
+ fmt.Printf("label %s doesn't exist on this bug\n", change.Label)
+ default:
+ panic(fmt.Sprintf("unknown label change status %v", change.Status))
+ }
+ }
+
if err != nil {
return err
}