Search code examples
rubyhighline

How to remove newline from ask method in Highline library?


I need a way to remove the newline from the ask method included in highline. Here's my current code:

pass = ask( "Enter your password > " ) { |passman| passman.echo = false }

But whenever I run the that, the output is

Enter your password > 
(typing goes here)

and I wish for this to not have a newline character. Any suggestions?


Solution

  • doc: highline says:

    If the provided statement ends with a space or tab character, a newline will not be appended (output will be flush()ed).

    So try it with a space:

    pass = ask( "Enter your password > " ) { |passman| passman.echo = false }