-
Notifications
You must be signed in to change notification settings - Fork 55
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
feat: add name flag support for rules delete command #54
Conversation
- ensure id and name flags are mutually exclusive - added rule id pattern check - fixed bug that didn't report not found rule when id was used Close A0CLI-40
@@ -200,12 +203,44 @@ func deleteRulesCmd(cli *cli) *cobra.Command { | |||
Long: `Delete a rule: | |||
|
|||
auth0 rules delete --id "12345"`, | |||
PreRunE: func(cmd *cobra.Command, args []string) error { | |||
if flags.id != "" && flags.name != "" { | |||
return fmt.Errorf("TMI! 🤯 use either --name or --id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍭
ruleIDPattern := "^rul_[A-Za-z0-9]{16}$" | ||
re := regexp.MustCompile(ruleIDPattern) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal since this is a CLI, but typically you put MustCompile
lines in vars outside so you don't have to re-do it.
(We can keep it like this for this PR though, just wanted to share that compiling regexp is typically expensive if you're doing server side code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that makes sense, good to know, ty!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Thank you
Close A0CLI-40