File tree Expand file tree Collapse file tree 4 files changed +43
-1
lines changed
Expand file tree Collapse file tree 4 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ NClap.Help.ArgumentHelpOptions.IncludeNamedArgumentValueSyntax.set -> void
33NClap.Metadata.ArgumentSetAttribute.ExpandLogo.get -> bool
44NClap.Metadata.ArgumentSetAttribute.ExpandLogo.set -> void
55NClap.Parser.AttributeBasedArgumentDefinitionFactory
6+ NClap.Repl.ILoopClient.PromptWithColor.get -> NClap.Utilities.ColoredString?
7+ NClap.Repl.ILoopClient.PromptWithColor.set -> void
68NClap.Types.IArgumentValue.GetAttributes<T>() -> System.Collections.Generic.IEnumerable<T>
79static NClap.Help.ArgumentSetHelpOptionsExtensions.NoDescription(this NClap.Utilities.FluentBuilder<NClap.Help.ArgumentSetHelpOptions> builder) -> NClap.Utilities.FluentBuilder<NClap.Help.ArgumentSetHelpOptions>
810static NClap.Help.ArgumentSetHelpOptionsExtensions.NoEnumValues(this NClap.Utilities.FluentBuilder<NClap.Help.ArgumentSetHelpOptions> builder) -> NClap.Utilities.FluentBuilder<NClap.Help.ArgumentSetHelpOptions>
Original file line number Diff line number Diff line change @@ -31,6 +31,15 @@ public string Prompt
3131 set => Reader . LineInput . Prompt = value ;
3232 }
3333
34+ /// <summary>
35+ /// The loop prompt (with color).
36+ /// </summary>
37+ public ColoredString ? PromptWithColor
38+ {
39+ get => Reader . LineInput . Prompt ;
40+ set => Reader . LineInput . Prompt = value . GetValueOrDefault ( ColoredString . Empty ) ;
41+ }
42+
3443 /// <summary>
3544 /// The character that starts a comment.
3645 /// </summary>
Original file line number Diff line number Diff line change 11using NClap . ConsoleInput ;
2+ using NClap . Utilities ;
23
34namespace NClap . Repl
45{
@@ -8,10 +9,16 @@ namespace NClap.Repl
89 public interface ILoopClient
910 {
1011 /// <summary>
11- /// The loop prompt.
12+ /// The loop prompt. If you wish to use a <see cref="ColoredString"/> as your
13+ /// prompt, you should use the <see cref="PromptWithColor"/> property instead.
1214 /// </summary>
1315 string Prompt { get ; set ; }
1416
17+ /// <summary>
18+ /// The loop prompt (with color).
19+ /// </summary>
20+ ColoredString ? PromptWithColor { get ; set ; }
21+
1522 /// <summary>
1623 /// The character that starts a comment.
1724 /// </summary>
Original file line number Diff line number Diff line change @@ -91,6 +91,30 @@ public void TestThatPromptsAreObserved()
9191 lineInput . Received ( 1 ) . DisplayPrompt ( ) ;
9292 }
9393
94+ [ TestMethod ]
95+ public void TestThatColoredPromptsAreObserved ( )
96+ {
97+ var prompt = new ColoredString ( "[Prompt!] " , ConsoleColor . Cyan ) ;
98+
99+ var reader = Substitute . For < IConsoleReader > ( ) ;
100+ var lineInput = Substitute . For < IConsoleLineInput > ( ) ;
101+
102+ lineInput . Prompt = prompt ;
103+ reader . LineInput . Returns ( lineInput ) ;
104+
105+ var client = new ConsoleLoopClient ( reader ) ;
106+ client . Prompt . Should ( ) . Be ( prompt ) ;
107+
108+ var newPrompt = new ColoredString ( "NewPrompt" , ConsoleColor . Green ) ;
109+ client . PromptWithColor = newPrompt ;
110+ client . PromptWithColor . Should ( ) . Be ( newPrompt ) ;
111+ client . Prompt . Should ( ) . Be ( newPrompt . ToString ( ) ) ;
112+ lineInput . Prompt . Should ( ) . Be ( newPrompt ) ;
113+
114+ client . DisplayPrompt ( ) ;
115+ lineInput . Received ( 1 ) . DisplayPrompt ( ) ;
116+ }
117+
94118 [ TestMethod ]
95119 public void TestThatReadLineWorksAsExpected ( )
96120 {
You can’t perform that action at this time.
0 commit comments