Prompting a user for a secret is not too uncommon, especially when 
building CLI applications. Due to an issue that has remained unresolved for 
many years 
<http://erlang.org/pipermail/erlang-questions/2014-July/080273.html>, 
:io.get_password() does not work when invoked in a Mix task or through 
escript. This is unfortunate as I would guess that these are the primary 
environments that users are likely to use that function. I believe that 
Elixir would benefit from a standard method that can accomplish this 
functionality both in normal operation and in the environments mentioned 
above.

Hex currently has an implementation that appears to be stable 
<https://github.com/hexpm/hex/blob/28dbfb9ae51099d1fcb2ce91b94a1dab9216e5d8/lib/mix/tasks/hex.ex#L371>,
 
and I believe it would suitable to adopt it as a utility method in 
Kernel.IO. Ideally, the behavior would wrap the Erlang library similar to 
how other functions in the module do, however, I feel the logic to 
compensate for the problem in :io would either require matching the error 
tuple:

{:error, {:request, {:get_password, :unicode}}}

or checking environment conditions to see if the Erlang method is likely to 
succeed, neither of which seem like a great solution.

If there is any reason that the Hex implemenation is not suitable as a 
standard in the absence of support from :io, I'm really interested, 
especially if there are portability issues.

In the mean time, I'll adopt the function into my own project with a 
reference to Hex :P



-- 
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/8724762b-428a-4aca-a4cf-bb9e0bed8e08o%40googlegroups.com.

Reply via email to