aboutsummaryrefslogtreecommitdiffstats
path: root/commands/id.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/id.go')
-rw-r--r--commands/id.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/commands/id.go b/commands/id.go
new file mode 100644
index 00000000..485c5457
--- /dev/null
+++ b/commands/id.go
@@ -0,0 +1,35 @@
+package commands
+
+import (
+ "fmt"
+
+ "github.com/MichaelMure/git-bug/identity"
+ "github.com/spf13/cobra"
+)
+
+func runId(cmd *cobra.Command, args []string) error {
+ id, err := identity.GetIdentity(repo)
+ if err != nil {
+ return err
+ }
+
+ fmt.Printf("Id: %s\n", id.Id())
+ fmt.Printf("Identity: %s\n", id.DisplayName())
+ fmt.Printf("Name: %s\n", id.Name())
+ fmt.Printf("Login: %s\n", id.Login())
+ fmt.Printf("Email: %s\n", id.Email())
+ fmt.Printf("Protected: %v\n", id.IsProtected())
+
+ return nil
+}
+
+var idCmd = &cobra.Command{
+ Use: "id",
+ Short: "Display or change the user identity",
+ PreRunE: loadRepo,
+ RunE: runId,
+}
+
+func init() {
+ RootCmd.AddCommand(idCmd)
+}