From 55006d8974dd8f5ef028df5bc75f884e27589b0f Mon Sep 17 00:00:00 2001 From: royroyee Date: Fri, 16 Feb 2024 16:00:54 +0900 Subject: [PATCH] Fix token creation command --- cmd/token/token_create.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/token/token_create.go b/cmd/token/token_create.go index 0738632..16289ec 100644 --- a/cmd/token/token_create.go +++ b/cmd/token/token_create.go @@ -23,7 +23,7 @@ var tokenCreateCmd = &cobra.Command{ var tokenRequest auth.APITokenRequest var err error - if name == "" || (limit == false && expiresAt == 0) { + if name == "" || (limit == true && expiresAt == 0) { tokenRequest, err = promptForToken() if err != nil { utils.CliError("Error during token prompt: %v", err) @@ -31,7 +31,7 @@ var tokenCreateCmd = &cobra.Command{ } else { tokenRequest = auth.APITokenRequest{Name: name} - if !limit { + if limit && expiresAt > 0 { tokenRequest.ExpiresAt = utils.TimeFormat(expiresAt) } } @@ -57,14 +57,14 @@ func init() { var expiresAt int tokenCreateCmd.Flags().StringVarP(&name, "name", "n", "", "A name to remember the token easily.") - tokenCreateCmd.Flags().BoolVarP(&limit, "limit", "l", false, "Set to true to apply usage limits.") + tokenCreateCmd.Flags().BoolVarP(&limit, "limit", "l", true, "Set to true to apply usage limits.") tokenCreateCmd.Flags().IntVar(&expiresAt, "expiration-in-days", 0, "This token can be used by the specified time. (in days)") } func promptForToken() (auth.APITokenRequest, error) { var tokenRequest auth.APITokenRequest tokenRequest.Name = utils.PromptForRequiredInput("Token name:") - if !utils.PromptForBool("limit: ") { + if utils.PromptForBool("Limit: ") { tokenRequest.ExpiresAt = utils.TimeFormat(utils.PromptForIntInput("Valid through (in days): ")) } else { tokenRequest.ExpiresAt = nil