@@ -29,25 +29,25 @@ public void Interpret(string[] args)
29
29
ExitWithSuccess ( ) ;
30
30
}
31
31
32
- var parser = new CommandLine . Parser ( with => with . IgnoreUnknownArguments = true ) ;
32
+ var parser = new Parser ( with => with . IgnoreUnknownArguments = true ) ;
33
33
var options = new Options ( ) ;
34
34
35
35
if ( parser . ParseArguments ( args , options ) )
36
36
{
37
37
if ( options == null )
38
- Environment . Exit ( CommandLine . Parser . DefaultExitCodeFail ) ;
38
+ Environment . Exit ( Parser . DefaultExitCodeFail ) ;
39
39
40
- var plugin = plugins . FirstOrDefault ( x => x . Name == options . PlugInName ) ;
40
+ var plugin = plugins . FirstOrDefault ( x => x . Name == options . PluginName ) ;
41
41
if ( plugin == null )
42
- ExitWithFailure ( "Plugin does not exist: " + options . PlugInName ) ;
42
+ ExitWithFailure ( "Plugin does not exist: " + options . PluginName ) ;
43
43
44
44
var pluginOptionList = plugin . MakeOptions ( ) ;
45
45
46
46
var pluginArgs = args . Skip ( 1 ) . ToArray ( ) ;
47
47
if ( ! pluginArgs . ToList ( ) . Any ( ) ) {
48
48
// If the plugin's args are empty, print the plugin's help screen and exit.
49
49
foreach ( var pluginOptions in pluginOptionList ) {
50
- CommandLine . Parser . Default . ParseArguments ( pluginArgs , pluginOptions ) ;
50
+ Parser . Default . ParseArguments ( pluginArgs , pluginOptions ) ;
51
51
Console . WriteLine ( pluginOptions . GetUsage ( "" ) ) ;
52
52
}
53
53
ExitWithSuccess ( ) ;
@@ -72,16 +72,22 @@ public void ExitWithSuccess(string message = null)
72
72
73
73
public void ExitWithFailure ( string message = null )
74
74
{
75
- if ( string . IsNullOrWhiteSpace ( message ) )
76
- message = "fail" ;
77
- Logger . Error ( $ "✘ { message } ") ;
78
- Environment . Exit ( CommandLine . Parser . DefaultExitCodeFail ) ;
75
+ Logger . Error ( MakeErrorMessage ( message ) ) ;
76
+ Environment . Exit ( Parser . DefaultExitCodeFail ) ;
79
77
}
80
78
81
79
public void ExitWithFailure ( Exception exception = null )
82
80
{
83
- Logger . Error ( exception ?? new CommandFailedException ( ) , "✘ fail" ) ;
84
- Environment . Exit ( CommandLine . Parser . DefaultExitCodeFail ) ;
81
+ var ex = exception ?? new Exception ( "Unspecified failure" ) ;
82
+ Logger . Error ( ex , MakeErrorMessage ( ex . Message ) ) ;
83
+ Environment . Exit ( Parser . DefaultExitCodeFail ) ;
84
+ }
85
+
86
+ protected string MakeErrorMessage ( string message = null )
87
+ {
88
+ if ( string . IsNullOrWhiteSpace ( message ) )
89
+ message = "fail" ;
90
+ return $ "✘ { message } ";
85
91
}
86
92
87
93
public List < Plugin > FindPlugins ( )
@@ -96,8 +102,7 @@ public List<Plugin> FindPlugins()
96
102
97
103
public void InterpretPluginArguments ( string [ ] pluginArgs , IOptions pluginOptions )
98
104
{
99
- var isSuccessful = CommandLine
100
- . Parser
105
+ var isSuccessful = Parser
101
106
. Default
102
107
. ParseArguments ( pluginArgs , pluginOptions , ( verb , subOptions ) =>
103
108
{
0 commit comments