Skip to content

Commit

Permalink
feat: confirm to overwrite token file
Browse files Browse the repository at this point in the history
  • Loading branch information
5n7-sk committed Dec 9, 2020
1 parent 08c7406 commit 0a21141
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ func (c *CLI) StoreAccessToken(token string) error {
return err
}

if _, err := os.Stat(tokenPath); !os.IsNotExist(err) {
var overwrite bool
prompt := &survey.Confirm{
Message: "token file already exists; overwrite?",
}
if err := survey.AskOne(prompt, &overwrite); err != nil {
return err
}

if !overwrite {
return nil
}
}

var t = struct {
Token string `json:"token"`
}{Token: token}
Expand Down

0 comments on commit 0a21141

Please sign in to comment.