| 213 | } |
| 214 | |
| 215 | func showRuleCmd(cli *cli) *cobra.Command { |
| 216 | var inputs struct { |
| 217 | ID string |
| 218 | } |
| 219 | |
| 220 | cmd := &cobra.Command{ |
| 221 | Use: "show", |
| 222 | Args: cobra.MaximumNArgs(1), |
| 223 | Short: "Show a rule", |
| 224 | Long: rulesDeprecationDocumentationText + "Display information about a rule.", |
| 225 | Example: ` auth0 rules show |
| 226 | auth0 rules show <rule-id> |
| 227 | auth0 rules show <rule-id> --json |
| 228 | auth0 rules show <rule-id> --json-compact`, |
| 229 | RunE: func(cmd *cobra.Command, args []string) error { |
| 230 | if len(args) > 0 { |
| 231 | inputs.ID = args[0] |
| 232 | } else { |
| 233 | if err := ruleID.Pick(cmd, &inputs.ID, cli.rulePickerOptions); err != nil { |
| 234 | return err |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | var rule *management.Rule |
| 239 | |
| 240 | err := ansi.Waiting(func() error { |
| 241 | var err error |
| 242 | rule, err = cli.api.Rule.Read(cmd.Context(), inputs.ID) |
| 243 | return err |
| 244 | }) |
| 245 | |
| 246 | if err != nil { |
| 247 | return fmt.Errorf("failed to read rule with ID %q: %w", inputs.ID, err) |
| 248 | } |
| 249 | |
| 250 | cli.renderer.Warnf(rulesDeprecationLogText) |
| 251 | cli.renderer.RuleShow(rule) |
| 252 | |
| 253 | return nil |
| 254 | }, |
| 255 | } |
| 256 | |
| 257 | cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.") |
| 258 | cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.") |
| 259 | |
| 260 | return cmd |
| 261 | } |
| 262 | |
| 263 | func deleteRuleCmd(cli *cli) *cobra.Command { |
| 264 | cmd := &cobra.Command{ |