Skip to content

Commit

Permalink
✨ implement check command
Browse files Browse the repository at this point in the history
  • Loading branch information
Shieldine committed Jul 26, 2024
1 parent d871ae6 commit a4caf8b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions cmd/check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright © 2024 Shieldine <74987363+Shieldine@users.noreply.github.com>
*/
package cmd

import (
"fmt"
"github.com/Shieldine/git-profile/internal"
"github.com/spf13/cobra"
)

var checkCmd = &cobra.Command{
Use: "check",
Short: "Display the currently set credentials",
Long: `Check what credentials are currently set in the current project.`,
Run: func(cmd *cobra.Command, args []string) {
name, err := internal.GetUserName()

if err != nil {
fmt.Println("error: not a git repository or username not set")
} else {
fmt.Printf("Current name: %s\n", name)
}

email, err := internal.GetUserEmail()

if err != nil {
fmt.Println("error: not a git repository or email not set")
} else {
fmt.Printf("Current email: %s\n", email)
}
},
}

func init() {
rootCmd.AddCommand(checkCmd)
}

0 comments on commit a4caf8b

Please sign in to comment.