@@ -15,7 +15,7 @@ public static class ConsoleAppEngineHostBuilderExtensions
1515
1616 public static IHostBuilder UseConsoleAppEngine ( this IHostBuilder hostBuilder , string [ ] args , IConsoleAppInterceptor ? interceptor = null )
1717 {
18- if ( args . Length == 0 || ( args . Length == 1 && args [ 0 ] . Equals ( ListCommand , StringComparison . OrdinalIgnoreCase ) ) )
18+ if ( args . Length == 0 || ( args . Length == 1 && args [ 0 ] . Trim ( '-' ) . Equals ( ListCommand , StringComparison . OrdinalIgnoreCase ) ) )
1919 {
2020 ShowMethodList ( ) ;
2121 hostBuilder . ConfigureServices ( services =>
@@ -25,7 +25,7 @@ public static IHostBuilder UseConsoleAppEngine(this IHostBuilder hostBuilder, st
2525 } ) ;
2626 return hostBuilder ;
2727 }
28- if ( args . Length == 2 && args [ 0 ] . Equals ( HelpCommand , StringComparison . OrdinalIgnoreCase ) )
28+ if ( args . Length == 2 && args [ 0 ] . Trim ( '-' ) . Equals ( HelpCommand , StringComparison . OrdinalIgnoreCase ) )
2929 {
3030 var ( t , mi ) = GetTypeFromAssemblies ( args [ 1 ] ) ;
3131 if ( mi != null )
@@ -87,7 +87,6 @@ public static IHostBuilder UseConsoleAppEngine<T>(this IHostBuilder hostBuilder,
8787 {
8888 var method = typeof ( T ) . GetMethods ( BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ;
8989 var defaultMethod = method . FirstOrDefault ( x => x . GetCustomAttribute < CommandAttribute > ( ) == null ) ;
90- var hasList = method . Any ( x => x . GetCustomAttribute < CommandAttribute > ( ) ? . EqualsAny ( ListCommand ) ?? false ) ;
9190 var hasHelp = method . Any ( x => x . GetCustomAttribute < CommandAttribute > ( ) ? . EqualsAny ( HelpCommand ) ?? false ) ;
9291
9392 if ( args . Length == 0 )
@@ -113,18 +112,7 @@ public static IHostBuilder UseConsoleAppEngine<T>(this IHostBuilder hostBuilder,
113112 }
114113 }
115114
116- if ( ! hasList && args . Length == 1 && args [ 0 ] . Equals ( ListCommand , StringComparison . OrdinalIgnoreCase ) )
117- {
118- ShowMethodList ( ) ;
119- hostBuilder . ConfigureServices ( services =>
120- {
121- services . AddOptions < ConsoleLifetimeOptions > ( ) . Configure ( x => x . SuppressStatusMessages = true ) ;
122- services . AddSingleton < IHostedService , EmptyHostedService > ( ) ;
123- } ) ;
124- return hostBuilder ;
125- }
126-
127- if ( ! hasHelp && args . Length == 1 && args [ 0 ] . Equals ( HelpCommand , StringComparison . OrdinalIgnoreCase ) )
115+ if ( ! hasHelp && args . Length == 1 && args [ 0 ] . Trim ( '-' ) . Equals ( HelpCommand , StringComparison . OrdinalIgnoreCase ) )
128116 {
129117 Console . Write ( new CommandHelpBuilder ( ) . BuildHelpMessage ( method , defaultMethod ) ) ;
130118
@@ -209,7 +197,7 @@ static List<Type> GetConsoleAppTypes()
209197 {
210198 if ( cmdattr . CommandNames . Any ( x => arg0 . Equals ( x , StringComparison . OrdinalIgnoreCase ) ) )
211199 {
212- if ( foundType != null && foundMethod != null )
200+ if ( foundType != null && foundMethod != null )
213201 {
214202 throw new InvalidOperationException ( $ "Duplicate ConsoleApp Command name is not allowed, { foundType . FullName } .{ foundMethod . Name } and { baseType . FullName } .{ method . Name } ") ;
215203 }
@@ -231,7 +219,7 @@ static List<Type> GetConsoleAppTypes()
231219 }
232220 }
233221 }
234- if ( foundType != null && foundMethod != null )
222+ if ( foundType != null && foundMethod != null )
235223 {
236224 return ( foundType , foundMethod ) ;
237225 }
0 commit comments