Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to override the way the prompt is written #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/ReadLine/ReadLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ static ReadLine()
public static void ClearHistory() => _history = new List<string>();
public static bool HistoryEnabled { get; set; }
public static IAutoCompleteHandler AutoCompletionHandler { private get; set; }

public static Action<string> WritePrompt { private get; set; } = (prompt) => Console.Write(prompt);

public static string Read(string prompt = "", string @default = "")
{
Console.Write(prompt);
WritePrompt(prompt);
KeyHandler keyHandler = new KeyHandler(new Console2(), _history, AutoCompletionHandler);
string text = GetText(keyHandler);

Expand All @@ -41,7 +42,7 @@ public static string Read(string prompt = "", string @default = "")

public static string ReadPassword(string prompt = "")
{
Console.Write(prompt);
WritePrompt(prompt);
KeyHandler keyHandler = new KeyHandler(new Console2() { PasswordMode = true }, null, null);
return GetText(keyHandler);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ReadLine/ReadLine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyTitle>ReadLine</AssemblyTitle>
<AssemblyDescription>A GNU-Readline like library for .NET/.NET Core</AssemblyDescription>
<AssemblyVersion>2.0.1</AssemblyVersion>
<AssemblyVersion>2.0.0</AssemblyVersion>
<Authors>Toni Solarin-Sodara</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<DebugType>portable</DebugType>
Expand Down