Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor string flags on apps and apis [CLI-70] #146

Merged
merged 5 commits into from
Mar 13, 2021
Merged

Refactor string flags on apps and apis [CLI-70] #146

merged 5 commits into from
Mar 13, 2021

Conversation

Widcket
Copy link
Contributor

@Widcket Widcket commented Mar 12, 2021

Description

This command encapsulates and extracts the repetitive logic to define, register, configure and prompt for the value of string flags on apps and apis commands.

  • Each flag is defined once in a struct instance that acts as a single source of truth for all the commands of a given resource
  • The prompt logic is abstracted away
  • The flag registration and configuration logic is abstracted away

Testing

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not master

@Widcket Widcket requested a review from cyx March 12, 2021 14:53
@@ -289,7 +287,7 @@ auth0 apis update <id> --name myapi
},
}

cmd.Flags().StringVarP(&inputs.Name, apiName, "n", "", "Name of the API.")
apiName.RegisterStringU(cmd, &inputs.Name)
cmd.Flags().StringVarP(&inputs.Scopes, apiScopes, "s", "", "Space-separated list of scopes.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scopes will be tackled on a future PR, as it needs to be changed from string flag to string slice flag, for consistency with other slice inputs

@Widcket Widcket changed the title Refactor string flags on apps and apis Refactor string flags on apps and apis [CLI-70] Mar 12, 2021
return ask(cmd, f, value, false)
}

func (f *Flag) AskU(cmd *cobra.Command, value interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does U stand for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It stands for "Update"

Copy link
Contributor

@cyx cyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@Widcket Widcket merged commit 36abf07 into main Mar 13, 2021
@Widcket Widcket deleted the flags-poc branch March 13, 2021 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants