-
Notifications
You must be signed in to change notification settings - Fork 58
Description
I am using minicli to develop a proof of concept, and I came across the need to read an input silently, as it is used to capture a password value. I had the idea of having a way to enable silent input reading in the framework. I imagine the implementation will be extremely straightforward and would like to bring this topic for discussion.
I believe we may only need a new method to read inputs without outputting what's being typed, where we can run a 'stty -echo' before getting the input and a 'stty echo' after getting the input.
Something like this:
// ON Input.php
public function read(bool $silently = false): string
{
$input = (string) $silently ? $this->readInputSilently() : readline($this->getPrompt());
$this->inputHistory[] = $input;
return $input;
}
private function readInputSilently(): string
{
echo $this->getPrompt();
system('stty -echo');
$input = trim(fgets(STDIN));
system('stty echo');
return $input;
}
If it is approved for implementation, may I proceed with it?
P.S. I apologize if this is not the correct way to open an issue seeking improvement; I am relatively new to contributing to the community.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status