mirror of
https://gitlab.durp.info/durfy/apps/durpcli.git
synced 2026-05-07 07:50:35 -05:00
update
This commit is contained in:
parent
d96fae1276
commit
125e0dc9cf
9 changed files with 167 additions and 83 deletions
37
cmd/auth/gettoken.go
Normal file
37
cmd/auth/gettoken.go
Normal 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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue