@@ -55,30 +55,24 @@ public void Interpret(string[] args)
5555 ExitWithSuccess ( ) ;
5656 }
5757
58+ var pluginArgs = args . ToArray ( ) ;
59+ var firstPluginArg = pluginArgs . FirstOrDefault ( ) ;
60+ var firstArgIsConf = firstPluginArg . StartsWith ( "-c" , StringComparison . OrdinalIgnoreCase ) ||
61+ firstPluginArg . StartsWith ( "--configuration" , StringComparison . OrdinalIgnoreCase ) ;
5862
59- var plugin = pluginAssemblies . FirstOrDefault ( x => x . Name == options . PluginName ) ;
60-
61- if ( plugin == null )
62- ExitWithFailure ( "Plugin does not exist: " + options . PluginName ) ;
63-
64- var pluginOptionList = plugin . Make < AbstractPlugin > ( ) ;
63+ if ( firstArgIsConf )
64+ pluginArgs = pluginArgs . Skip ( 1 ) . ToArray ( ) ;
6565
66- var pluginArgs = args . Skip ( 1 ) . ToArray ( ) ;
66+ var commandVerbName = pluginArgs . FirstOrDefault ( ) ;
6767
68- if ( ! pluginArgs . ToList ( ) . Any ( ) ) {
69- PrintPluginHelpTextAndExit ( plugin , pluginOptionList , pluginArgs ) ;
70- }
68+ foreach ( var assembly in pluginAssemblies )
69+ foreach ( var ops in assembly . Plugins )
70+ foreach ( var prop in ops . GetType ( ) . GetProperties ( ) )
71+ foreach ( object attr in prop . GetCustomAttributes ( true ) )
72+ if ( attr is VerbOptionAttribute commandVerb && ( commandVerb . LongName == commandVerbName || commandVerb . ShortName . ToString ( ) == commandVerbName ) )
73+ InterpretPluginArguments ( pluginArgs , ops ) ;
7174
72- if ( new [ ] { "-p" , "--plugin-name" , "-c" , "--configuration" } . Any ( c => pluginArgs . First ( ) . StartsWith ( "-p" , StringComparison . OrdinalIgnoreCase ) ) )
73- pluginArgs = pluginArgs . Skip ( 1 ) . ToArray ( ) ;
74-
75- // Need to remove plugin options
76- var commandVerbName = pluginArgs . First ( ) ;
77- foreach ( var ops in pluginOptionList )
78- foreach ( var prop in ops . GetType ( ) . GetProperties ( ) )
79- foreach ( object attr in prop . GetCustomAttributes ( true ) )
80- if ( attr is VerbOptionAttribute commandVerb && ( commandVerb . LongName == commandVerbName || commandVerb . ShortName . ToString ( ) == commandVerbName ) )
81- InterpretPluginArguments ( pluginArgs , ops ) ;
75+ PrintInEngineHelpTextAndExit ( pluginAssemblies , options ) ;
8276 }
8377 }
8478
@@ -169,11 +163,14 @@ public void PrintInEngineHelpTextAndExit(List<PluginAssembly> plugins, Options o
169163 {
170164 Write . Info ( CliLogo ) ;
171165 Write . Text ( options . GetUsage ( "" ) ) ;
172- Write . Newline ( ) ;
173- Write . Warning ( "Plugins:" ) ;
174- plugins . ForEach ( x => Write . Line ( $ " { x . Name } ") ) ;
175- Write . Newline ( 2 ) ;
176- ExitWithSuccess ( ) ;
166+ plugins . ForEach ( x => {
167+ Write . Warning ( x . Name ) ;
168+ x . Plugins . ForEach ( y => {
169+ Write . Line ( string . Join ( Environment . NewLine , y . GetUsageWithoutHeader ( ) . Split ( '\n ' ) . Where ( s => ! string . IsNullOrWhiteSpace ( s ) ) ) )
170+ . Newline ( ) ;
171+ } ) ;
172+ } ) ;
173+ ExitWithSuccess ( ) ;
177174 }
178175 }
179176}
0 commit comments