cmd/route-cli: add 'token rm' command

This commit is contained in:
Cadey Ratio 2017-10-01 22:25:04 -07:00
parent 3ee292925d
commit 4f4f0d2214
No known key found for this signature in database
GPG Key ID: D607EE27C2E7F89A
1 changed files with 23 additions and 0 deletions

View File

@ -331,6 +331,29 @@ retry_netrc:
json.NewEncoder(os.Stdout).Encode(tkn)
return
case "token rm":
tkn, err := tc.Get(ctx, &proto.GetTokenRequest{Id: *tokenRmID})
if err != nil {
ln.FatalErr(ctx, err, ln.Action("fetch token from server"), ln.F{"token_id": *tokenRmID})
}
var action ln.Fer
if *tokenRmHard {
_, err = tc.Delete(ctx, tkn)
action = ln.Action("actually delete token")
} else {
_, err = tc.Deactivate(ctx, tkn)
action = ln.Action("deactivate token")
}
if err != nil {
ln.FatalErr(ctx, err, ln.F{"token_id": *tokenRmID}, action)
}
fmt.Printf("token with id %s and body %s removed.\n", tkn.Id, tkn.Body)
return
}