From feab9412dffe5772048aad29893c4cb01d566387 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Wed, 21 Nov 2018 18:56:12 +0100 Subject: WIP identity in git --- commands/id.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 commands/id.go (limited to 'commands') 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) +} -- cgit