Skip to content

Commit

Permalink
initial token impl
Browse files Browse the repository at this point in the history
  • Loading branch information
doneill committed Nov 23, 2023
1 parent 3a21cee commit 86cc3ce
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions cmd/token.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// ----------------------------------------------
// token command
// ----------------------------------------------

var tokenCmd = &cobra.Command{
Use: "token",
Short: "Display token",
Long: `Return the current users token`,
Run: func(cmd *cobra.Command, args []string) {
token()
},
}

// ----------------------------------------------
// funtions
// ----------------------------------------------

func token() {
if err := viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
fmt.Println("Error: er not configured properly, try reauthenticating")
} else {
fmt.Println("Error:", err)
}
} else {
var token = viper.Get("oauth_token")
fmt.Println(token)
}
}

// ----------------------------------------------
// initialize
// ----------------------------------------------

func init() {
authCmd.AddCommand(tokenCmd)
}

0 comments on commit 86cc3ce

Please sign in to comment.