diff --git a/cmd/route-cli/main.go b/cmd/route-cli/main.go index 8512151..5fa728c 100644 --- a/cmd/route-cli/main.go +++ b/cmd/route-cli/main.go @@ -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 }