1package commands
2
3import (
4 "fmt"
5
6 "github.com/MichaelMure/git-bug/identity"
7 "github.com/spf13/cobra"
8)
9
10func runId(cmd *cobra.Command, args []string) error {
11 id, err := identity.GetIdentity(repo)
12 if err != nil {
13 return err
14 }
15
16 fmt.Printf("Id: %s\n", id.Id())
17 fmt.Printf("Identity: %s\n", id.DisplayName())
18 fmt.Printf("Name: %s\n", id.Name())
19 fmt.Printf("Login: %s\n", id.Login())
20 fmt.Printf("Email: %s\n", id.Email())
21 fmt.Printf("Protected: %v\n", id.IsProtected())
22
23 return nil
24}
25
26var idCmd = &cobra.Command{
27 Use: "id",
28 Short: "Display or change the user identity",
29 PreRunE: loadRepo,
30 RunE: runId,
31}
32
33func init() {
34 RootCmd.AddCommand(idCmd)
35}