X Tutup
Skip to content

Fix "command.PromptForConfirmation" to accept "enter" for the "N" default#30769

Merged
LK4D4 merged 1 commit intomoby:masterfrom
tianon:prompt-for-confirmation
Feb 6, 2017
Merged

Fix "command.PromptForConfirmation" to accept "enter" for the "N" default#30769
LK4D4 merged 1 commit intomoby:masterfrom
tianon:prompt-for-confirmation

Conversation

@tianon
Copy link
Member

@tianon tianon commented Feb 6, 2017

- What I did

This adjusts command.PromptForConfirmation in cli/command/utils.go to use bufio's ReadLine rather than using fmt.Fscan for reading input, which makes <Enter> properly accept the default value of "No" as one would expect.

- How I did it

This new code actually came from cli/command/plugin/install.go's acceptPrivileges function, which I've also refactored here to use command.PromptForConfirmation as it should.

- How to verify it

I verified it by running ./bundles/latest/dynbinary-client/docker system prune and testing different combinations of responses (just <Enter>, y, Y, n, N, bogus), and verifying that only y and Y try to reclaim space.

- Description for the changelog

  • Fixed "default answer" handling in y/N prompts

- A picture of a cute animal (not mandatory but encouraged)

image

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Can you do the same for plugin/upgrade?

Copy link
Member Author

Choose a reason for hiding this comment

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

I searched for all instances of y/N in the code to find this one -- guess that one doesn't include y/N 😄

Changing it now!

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated ❤️

…ault

This adjusts `command.PromptForConfirmation` in `cli/command/utils.go` to use `bufio`'s `ReadLine` rather than using `fmt.Fscan` for reading input, which makes `<Enter>` properly accept the default value of "No" as one would expect.

This new code actually came from `cli/command/plugin/install.go`'s `acceptPrivileges` function, which I've also refactored here to use `command.PromptForConfirmation` as it should.

Additionally, this updates `cli/command/plugin/upgrade.go`'s `runUpgrade` function to use `command.PromptForConfirmation` for further consistency.

Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
@tianon tianon force-pushed the prompt-for-confirmation branch from 5af525c to 2198b05 Compare February 6, 2017 17:13
Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

@anusha-ragunathan
Copy link
Contributor

LGTM

1 similar comment
@LK4D4
Copy link
Contributor

LK4D4 commented Feb 6, 2017

LGTM

@LK4D4 LK4D4 merged commit d4136eb into moby:master Feb 6, 2017
@GordonTheTurtle GordonTheTurtle added this to the 1.14.0 milestone Feb 6, 2017
@tianon tianon deleted the prompt-for-confirmation branch February 6, 2017 19:46
dnephin pushed a commit to dnephin/docker that referenced this pull request Apr 17, 2017
Fix "command.PromptForConfirmation" to accept "enter" for the "N" default
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.

7 participants

X Tutup