@@ -129,12 +129,6 @@ public virtual async Task<int> ProcessCommandAsync(string[] cmdLine, Cancellatio
129129 return CommandResult . NotHandled ;
130130 }
131131 var parseResult = _allCommands . Parse ( cmdLine ) ;
132- if ( parseResult . Errors . Count > 0 )
133- {
134- WriteArgErrors ( parseResult ) ;
135- return CommandResult . NotHandled ;
136- }
137-
138132 return await parseResult . InvokeAsync ( null , cancellationToken ) . ConfigureAwait ( false ) ;
139133 }
140134
@@ -145,7 +139,7 @@ async Task<int> EvalInputAsync(string input, CancellationToken cancellationToken
145139 {
146140 try
147141 {
148- return input . StartsWith ( CommandPrefix )
142+ return ( input . StartsWith ( CommandPrefix ) || IsHelp ( input ) )
149143 ? await EvalCommandAsync ( input , cancellationToken ) . ConfigureAwait ( false )
150144 : await EvalLineAsync ( input , cancellationToken ) . ConfigureAwait ( false ) ;
151145 }
@@ -203,6 +197,30 @@ bool IsStop(string? line)
203197 return line is not null ? line . Trim ( ) : line ;
204198 }
205199
200+ public void AddModule ( ICommandModule module )
201+ {
202+ _allCommands . AddModule ( module ) ;
203+ }
204+
205+ public void AddModules ( params ICommandModule [ ] modules )
206+ {
207+ foreach ( var module in modules )
208+ {
209+ AddModule ( module ) ;
210+ }
211+ }
212+
213+ public void SortCommands ( )
214+ {
215+ var commands = _allCommands . Subcommands . ToList ( ) ;
216+ _allCommands . Subcommands . Clear ( ) ;
217+ commands . Sort ( ( x , y ) => x . Name . CompareTo ( y . Name ) ) ;
218+ foreach ( var cmd in commands )
219+ {
220+ _allCommands . Add ( cmd ) ;
221+ }
222+ }
223+
206224 protected virtual void OnException ( string input , Exception ex )
207225 {
208226 Console . WriteLine ( "## Could not process request" ) ;
@@ -231,27 +249,8 @@ protected void WriteArgErrors(ParseResult parseResult)
231249 }
232250 }
233251
234- public void AddModule ( ICommandModule module )
235- {
236- _allCommands . AddModule ( module ) ;
237- }
238-
239- public void AddModules ( params ICommandModule [ ] modules )
240- {
241- foreach ( var module in modules )
242- {
243- AddModule ( module ) ;
244- }
245- }
246-
247- public void SortCommands ( )
252+ private bool IsHelp ( string value )
248253 {
249- var commands = _allCommands . Subcommands . ToList ( ) ;
250- _allCommands . Subcommands . Clear ( ) ;
251- commands . Sort ( ( x , y ) => x . Name . CompareTo ( y . Name ) ) ;
252- foreach ( var cmd in commands )
253- {
254- _allCommands . Add ( cmd ) ;
255- }
254+ return value == "--help" || value == "--?" || value == "-?" ;
256255 }
257256}
0 commit comments