-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |