Oh, this is my first proposal so if I have forgotten anything just let me 
know :)

On Saturday, 10 April 2021 at 13:23:11 UTC+1 Darragh Enright wrote:

> Hi there!
>
> I am currently writing some interactive mix tasks in a project I am 
> writing and I noticed that *Mix.Shell.IO.yes?* accepts any trimmed input 
> that matches the following allowlist of values:
>
> *["", "y", "Y", "yes", "YES", "Yes"]*
>
> However, it struck me that allowing what I'll call an "implicit" 
> confirmation with the Enter key is sometimes dangerous; e.g:
>
> *>>> Are you sure you want to continue with this very dangerous, 
> irreversible operation? [Yn]"*
>
> Dangerous is highly contextual of course, but I'd love to have an option 
> that requires the user to explicitly type their confirmation — in this case 
> the Enter key would be a cancel input instead, and make the function return 
> false.
>
> I had a look at the code in *lib/mix/lib/mix/shell/io.ex* and it seems 
> like a straightforward change — I'd be happy to contribute if this proposal 
> were acceptable.
>
> The change would look something like this:
>
> Add an option; e.g: 
>
> *Mix.Shell.IO.yes?("Are you sure?", explicit_yes?: true)*
>
> The option could alternatively be called :explicit?, :strict, 
> :enter_cancels? or something else — whatever is considered most idiomatic.
>
> Of course, this would also change the prompt slightly to indicate the 
> behaviour of implicit input; e.g:
>
> *Are you sure? [yN]*
>
> Instead of:
>
> *Are you sure? [Yn]*
>
> Existing behaviour of this function would remain unchanged; this option 
> would default to false and Enter would be accepted as prompt confirmation 
> as before.
>
> Additionally, looking at the source code — I wonder should the accepted 
> input be case-insensitive, and allow values like "yEs" or is the 
> aforementioned allowlist comprised of explicit values for a specific reason?
>
> Thanks!
> Darragh
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/d36cfae3-13f1-4204-9f3d-f01eaf511c70n%40googlegroups.com.

Reply via email to