MCPcopy Create free account
hub / github.com/auth0/auth0-cli / deleteRuleCmd

Function deleteRuleCmd

internal/cli/rules.go:263–311  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

261}
262
263func deleteRuleCmd(cli *cli) *cobra.Command {
264 cmd := &cobra.Command{
265 Use: "delete",
266 Aliases: []string{"rm"},
267 Short: "Delete a rule",
268 Long: rulesDeprecationDocumentationText + "Delete a rule.\n\n" +
269 "To delete interactively, use `auth0 rules delete` with no arguments.\n\n" +
270 "To delete non-interactively, supply the rule id and the `--force` flag to skip confirmation.",
271 Example: ` auth0 rules delete
272 auth0 rules rm
273 auth0 rules delete <rule-id>
274 auth0 rules delete <rule-id> --force
275 auth0 rules delete <rule-id> <rule-id2> <rule-idn>
276 auth0 rules delete <rule-id> <rule-id2> <rule-idn> --force`,
277 RunE: func(cmd *cobra.Command, args []string) error {
278 var ids []string
279 if len(args) == 0 {
280 if err := ruleID.PickMany(cmd, &ids, cli.rulePickerOptions); err != nil {
281 return err
282 }
283 } else {
284 ids = args
285 }
286
287 if !cli.force && canPrompt(cmd) {
288 if confirmed := prompt.Confirm("Are you sure you want to proceed?"); !confirmed {
289 return nil
290 }
291 }
292
293 return ansi.ProgressBar("Deleting Rule(s)", ids, func(_ int, id string) error {
294 if id != "" {
295 if _, err := cli.api.Rule.Read(cmd.Context(), id); err != nil {
296 return fmt.Errorf("failed to delete rule with ID %q: %w", id, err)
297 }
298
299 if err := cli.api.Rule.Delete(cmd.Context(), id); err != nil {
300 return fmt.Errorf("failed to delete rule with ID %q: %w", id, err)
301 }
302 }
303 return nil
304 })
305 },
306 }
307
308 cmd.Flags().BoolVar(&cli.force, "force", false, "Skip confirmation.")
309
310 return cmd
311}
312
313func updateRuleCmd(cli *cli) *cobra.Command {
314 var inputs struct {

Callers 1

rulesCmdFunction · 0.85

Calls 7

ConfirmFunction · 0.92
ProgressBarFunction · 0.92
canPromptFunction · 0.85
ErrorfMethod · 0.80
ReadMethod · 0.65
DeleteMethod · 0.65
PickManyMethod · 0.45

Tested by

no test coverage detected