Add support for terminals that redirect input such as MINGW64#3
Add support for terminals that redirect input such as MINGW64#3augustoproiete wants to merge 1 commit intoVerifyTests:mainfrom
Conversation
|
N.B.: @patriksvensson This is only updating the |
| @@ -81,41 +86,38 @@ public override int Execute( | |||
| } | |||
|
|
|||
| private static SnapshotAction ShowPrompt() | |||
There was a problem hiding this comment.
There is no longer a loop until the user submits a valid command. We need to add that.
There was a problem hiding this comment.
@patriksvensson The loop is there, it's just been moved up in the call stack. Typing anything other than a valid command will re-render the diff and ask for the prompt again.
| } | ||
|
|
||
| private static SnapshotAction ShowPrompt() | ||
| { |
There was a problem hiding this comment.
I would also want this functionality to be a fallback method instead of replacing what we currently have. We can check if the input has been redirected, and fallback to this new functionality.
There was a problem hiding this comment.
@patriksvensson Sure, this is definitely possible to do - technically speaking that is -, but are you sure this is a good idea? 🤔 There are many consoles that redirect the input, including the terminal in Visual Studio Code... So a user could easily have different UX using this tool on the same machine depending on the terminal they happen to be using each time... Seems a little odd if you ask me.
Also, using ReadLine for prompting for an answer is the approach we see on popular command-line tools like Git, Homebrew, npm, AWS Cli, Azure Cli, and many others... Can you think of any modern/popular command-line tools that use ReadKey? I suspect there aren't many because of this exact limitation on input redirection...
There was a problem hiding this comment.
Yes, "Insta" which I based this tool on, for one.
I don't want to have to press enter for each file when I review them, so if stdin isn't redirected (the usual case when running an interactive app), I want to grab input without having to press enter if possible.
Given that it's not possible to use
Console.ReadKeywhen the input is redirected, I'm suggesting an approach usingConsole.ReadLineto display a prompt (with a visible cursor).In other words, the user now has to hit
<enter>after typing one of the letters (a,r, ors).As a bonus, the full words
accept,reject, andskipare also valid.Closes #1