-
Notifications
You must be signed in to change notification settings - Fork 396
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
[Fixs #109] Adding confirmation on delete actions #148
Conversation
Update 10/06/2016:First of all I did some I have improved question, it is not over 4 lines, it is only in one line now:
This involved creation of new CI is still unresolved, but it will be soon. :) |
Update 10/07/2016 - whole changelog:confirmation.go:Confirmation input is changed to be in fashion like confirmation_test.goI created basic test unit that test:
I made sure that it uses doit.goAdded global bool flag - droplets.goImplemented ask for confirmation. droplets_test.goAdded errors.goAdded
As I wanted it to be in one line e.g. :
I created new function Comments:My main concern is |
@@ -77,6 +80,7 @@ func init() { | |||
DoitCmd.PersistentFlags().StringVarP(&Token, "access-token", "t", "", "API V2 Access Token") | |||
DoitCmd.PersistentFlags().StringVarP(&Output, "output", "o", "text", "output format [text|json]") | |||
DoitCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "verbose output") | |||
DoitCmd.PersistentFlags().BoolVarP(&Force, "force", "f", false, "force execution") |
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.
Should force
be global option or is it specific to the command?
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.
For now I was thinking about adding it only to RunDropletDelete
. Because at every other command it is unusable, actually it would do nothing.
This way was like, most easiest, I would be able to use both --force
& -f
and it worked.
At first I wanted to make it only for RunDropletDelete
, so I used AddBoolFlag but I was not sure how to add alias to it (--force
and -f
) and what to add in doit.go
for it.
@bryanl It's ready to be merged, I think.
One drawback of it is that it need to be called with |
@xmudrii There is an issue with short flags. I've seen it before, but haven't tracked down the culprit in pflags. |
aliasOpt("d", "del", "rm"), docCategories("droplet")) | ||
AddBoolFlag(cmdRunDropletDelete, doctl.ArgDeleteForce, false, "Froce droplet delete") |
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.
typo :)
@bryanl didn't noticed, it happens :D Fixed typo. |
When doctl is used within automation how do we "bypass" the dialog or perform "--non-interactive" actions? |
You can do it by using force flag, e.g. doctl compute droplet delete id --force. :) |
Fixs #109
Continues work from #110
@bryanl I would like review if possible, in free time ofc. :D
Adding confirmation on delete actions
This is basic yes/no confirmation. User need to answer
y
,ye
oryes
. For every other answer, command will be stopped.For now it is only implemented for Droplet delete action.
List of done things that are working:
confirmation.go
confirmation.go
droplets.go
Things could be done:
Explanation
First of all I created confirmation.go because of reusability. It would not be bad to extend it on volume delete, images delete, but this is something we will discuss later. Anyways I decided to make it reusable from beginning.
It is working like, you have to answer
y
oryes
(case doesn't matters as I convert it to lower). If you answer anything other, operation will be aborted.I added Force flag to
doit
, but I'm not sure is it right way, I would like some suggestion on this.