Skip to content

Commit ed22405

Browse files
authored
feat: raw token output in CLI (#907)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent 012ab72 commit ed22405

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/cli/cmd/organization_apitoken_create.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,20 @@ func newAPITokenCreateCmd() *cobra.Command {
4545
return fmt.Errorf("creating API token: %w", err)
4646
}
4747

48+
if flagOutputFormat == "token" {
49+
fmt.Print(res.JWT)
50+
return nil
51+
}
52+
4853
return encodeOutput([]*action.APITokenItem{res}, apiTokenListTableOutput)
4954
},
5055
}
5156

5257
cmd.Flags().StringVar(&description, "description", "", "API token description")
5358
cmd.Flags().DurationVar(&expiresIn, "expiration", 0, "optional API token expiration, in hours i.e 1h, 24h, 178h (week), ...")
5459
cmd.Flags().StringVar(&name, "name", "", "token name")
60+
// Override default output flag
61+
cmd.InheritedFlags().StringVarP(&flagOutputFormat, "output", "o", "table", "output format, valid options are table, json, token")
5562
err := cmd.MarkFlagRequired("name")
5663
cobra.CheckErr(err)
5764

0 commit comments

Comments
 (0)