aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-01-17 03:09:08 +0100
committerMichael Muré <batolettre@gmail.com>2019-03-01 22:35:37 +0100
commitbdbe9e7e8256fff820efe1ce707e7154d517ecb3 (patch)
tree82b86c7f89c6c9796b1c7b26beea350afa634d6f /commands
parent3df4f46c71650c9d23b267c44afec16f1b759e92 (diff)
downloadgit-bug-bdbe9e7e8256fff820efe1ce707e7154d517ecb3.tar.gz
identity: more progress and fixes
Diffstat (limited to 'commands')
-rw-r--r--commands/id.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/commands/id.go b/commands/id.go
index 485c5457..44294132 100644
--- a/commands/id.go
+++ b/commands/id.go
@@ -1,6 +1,7 @@
package commands
import (
+ "errors"
"fmt"
"github.com/MichaelMure/git-bug/identity"
@@ -8,7 +9,19 @@ import (
)
func runId(cmd *cobra.Command, args []string) error {
- id, err := identity.GetIdentity(repo)
+ if len(args) > 1 {
+ return errors.New("only one identity can be displayed at a time")
+ }
+
+ var id *identity.Identity
+ var err error
+
+ if len(args) == 1 {
+ id, err = identity.Read(repo, args[0])
+ } else {
+ id, err = identity.GetIdentity(repo)
+ }
+
if err != nil {
return err
}
@@ -24,7 +37,7 @@ func runId(cmd *cobra.Command, args []string) error {
}
var idCmd = &cobra.Command{
- Use: "id",
+ Use: "id [<id>]",
Short: "Display or change the user identity",
PreRunE: loadRepo,
RunE: runId,
@@ -32,4 +45,5 @@ var idCmd = &cobra.Command{
func init() {
RootCmd.AddCommand(idCmd)
+ selectCmd.Flags().SortFlags = false
}