This commit is contained in:
2024-06-23 16:27:55 -05:00
parent d96fae1276
commit 125e0dc9cf
9 changed files with 167 additions and 83 deletions

37
cmd/auth/gettoken.go Normal file
View File

@@ -0,0 +1,37 @@
package auth
import (
"fmt"
"log"
"os/user"
"github.com/spf13/cobra"
"github.com/zalando/go-keyring"
)
var getTokenCmd = &cobra.Command{
Use: "get token",
Short: "",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
gettokn()
},
}
func init() {
AuthCmd.AddCommand(getTokenCmd)
}
func gettokn() {
service := "durpcli"
user, _ := user.Current()
token, err := keyring.Get(service, user.Username)
if err != nil {
log.Fatal(err)
}
fmt.Println(token)
}