Parse token flag before accessing keyring (#359)
This commit is contained in:
parent
7cf779f521
commit
5805f6605e
1 changed files with 12 additions and 6 deletions
18
main.go
18
main.go
|
|
@ -10,14 +10,20 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
t, err := keyring.Get(constants.Name, "token")
|
||||
if err != nil {
|
||||
log.Println("token not found in keyring:", err)
|
||||
}
|
||||
|
||||
token := flag.String("token", t, "The authentication token.")
|
||||
// Declare and parse all flags first
|
||||
token := flag.String("token", "", "The authentication token.")
|
||||
flag.Parse()
|
||||
|
||||
// If no token was provided, look it up in the keyring
|
||||
if *token == "" {
|
||||
t, err := keyring.Get(constants.Name, "token")
|
||||
if err != nil {
|
||||
log.Println("Authentication token not found in keyring:", err)
|
||||
} else {
|
||||
*token = t
|
||||
}
|
||||
}
|
||||
|
||||
if err := cmd.Run(*token); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue