Search code examples
erlangcommand-line-interfaceelixirerlang-escript

Elixir or Erlang prompt for password with hidden input


I'm writing a CLI in elixir, how can I prompt the user for a password, without displaying the input in the terminal?


Solution

  • Apparently there are some problems with this. Currently the best solution seems to be to repeatedly clear the input in a loop, as implemented in the Hex package manager:

    https://github.com/hexpm/hex/blob/1523f44e8966d77a2c71738629912ad59627b870/lib/mix/hex/utils.ex#L32-L58