Skip to content

Conversation

@derekbekoe
Copy link
Member

@derekbekoe derekbekoe commented Jan 18, 2017

Closes #1355

  • When registering a command, add confirmation=True to enable user confirmation. Also supports a string message or callable.
  • Add a —force flag for commands that support this feature.
  • Integrated with configuration system so it can be enabled/disabled by setting AZURE_CORE_DISABLE_CONFIRM_PROMPT

Added for the following commands:
az group delete
az vm delete
az network dns zone delete


EXAMPLES:

$ az group delete -n debekoe-a3
Are you sure you want to perform this operation? (y/n): n
Operation cancelled.

Only accepts appropriate values.

$ az group delete -n debekoe-a3
Are you sure you want to perform this operation? (y/n): 1
Are you sure you want to perform this operation? (y/n): 2
Are you sure you want to perform this operation? (y/n): 3
Are you sure you want to perform this operation? (y/n): n
Operation cancelled.
$ az group delete -n debekoe-a3 --force
$

No TTY:

$ az group delete -n debekoe-a3
Unable to prompt for confirmation as no tty available. Use --force.
Operation cancelled.

@derekbekoe
Copy link
Member Author

Only added it for these commands:
az group delete
az vm delete
az network dns zone delete

Are there any other critical ones we should add it for @tjprescott & @johanste?

@tjprescott
Copy link
Member

I believe the port does this for all delete operations, so I would lean toward that.

Copy link
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

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

A question but overall LGTM.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not entirely sure I understand this. There are three cases:

  1. True => default prompt enabled
  2. callable => you have access to the command namespace (?) and return true or false? Do we use this?
  3. string => enables the prompt with a custom message.

Does using #2 mean you essentially are using your own handler and throwing away the default one?

Copy link
Member Author

Choose a reason for hiding this comment

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

Your understanding of 1 & 3 is correct.
For 2, you can specify your own confirmation prompt handler. You get the command namespace so you can use it if required. e.g. Print a custom prompt based on the name of one of the parameters.

And no we do not currently use 2 or 3 but there are use-cases where they'll be useful.

Copy link
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

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

I'd recommend a second set of eyes, but LGTM.

- When registering a command, add `confirmation=True` to enable user confirmation. Also supports a string message or callable.
- Add a —force flag for commands that support this feature.
- Integrated with configuration system so it can be enabled/disabled by setting AZURE_CORE_DISABLE_CONFIRM_PROMPT

Added for the following commands:
az group delete
az vm delete
az network dns zone delete
@derekbekoe derekbekoe merged commit f274679 into Azure:master Jan 20, 2017
@derekbekoe derekbekoe deleted the force-confirm branch January 20, 2017 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants