File tree 4 files changed +43
-1
lines changed
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
3
3
NClap.Metadata.ArgumentSetAttribute.ExpandLogo.get -> bool
4
4
NClap.Metadata.ArgumentSetAttribute.ExpandLogo.set -> void
5
5
NClap.Parser.AttributeBasedArgumentDefinitionFactory
6
+ NClap.Repl.ILoopClient.PromptWithColor.get -> NClap.Utilities.ColoredString?
7
+ NClap.Repl.ILoopClient.PromptWithColor.set -> void
6
8
NClap.Types.IArgumentValue.GetAttributes<T>() -> System.Collections.Generic.IEnumerable<T>
7
9
static NClap.Help.ArgumentSetHelpOptionsExtensions.NoDescription(this NClap.Utilities.FluentBuilder<NClap.Help.ArgumentSetHelpOptions> builder) -> NClap.Utilities.FluentBuilder<NClap.Help.ArgumentSetHelpOptions>
8
10
static 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
31
31
set => Reader . LineInput . Prompt = value ;
32
32
}
33
33
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
+
34
43
/// <summary>
35
44
/// The character that starts a comment.
36
45
/// </summary>
Original file line number Diff line number Diff line change 1
1
using NClap . ConsoleInput ;
2
+ using NClap . Utilities ;
2
3
3
4
namespace NClap . Repl
4
5
{
@@ -8,10 +9,16 @@ namespace NClap.Repl
8
9
public interface ILoopClient
9
10
{
10
11
/// <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.
12
14
/// </summary>
13
15
string Prompt { get ; set ; }
14
16
17
+ /// <summary>
18
+ /// The loop prompt (with color).
19
+ /// </summary>
20
+ ColoredString ? PromptWithColor { get ; set ; }
21
+
15
22
/// <summary>
16
23
/// The character that starts a comment.
17
24
/// </summary>
Original file line number Diff line number Diff line change @@ -91,6 +91,30 @@ public void TestThatPromptsAreObserved()
91
91
lineInput . Received ( 1 ) . DisplayPrompt ( ) ;
92
92
}
93
93
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
+
94
118
[ TestMethod ]
95
119
public void TestThatReadLineWorksAsExpected ( )
96
120
{
You can’t perform that action at this time.
0 commit comments