aboutsummaryrefslogtreecommitdiffstats
path: root/commands/id.go
blob: 485c5457b36308f4b7c7a738b2db5240f57d863b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)
}