Skip to content

Commit 9903db2

Browse files
committed
Cleanup
1 parent e79e019 commit 9903db2

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

src/InEngine.Core/Queue/Commands/Publish.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public override CommandResult Run()
1515
{
1616
var command = Assembly.LoadFrom(CommandAssembly).CreateInstance(CommandClass) as ICommand;
1717
if (command == null)
18-
return new CommandResult(false, "Did not publish message. Could not load command from assembly.");
18+
return new CommandResult(false, "Did not publish message. Could not load command from plugin.");
1919
Broker.MakeBroker(this).Publish(command);
2020
return new CommandResult(true, "Published");
2121
}

src/InEngineCli/ArgumentInterpreter.cs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ public void Interpret(string[] args)
2929
ExitWithSuccess();
3030
}
3131

32-
var parser = new CommandLine.Parser(with => with.IgnoreUnknownArguments = true);
32+
var parser = new Parser(with => with.IgnoreUnknownArguments = true);
3333
var options = new Options();
3434

3535
if (parser.ParseArguments(args, options))
3636
{
3737
if (options == null)
38-
Environment.Exit(CommandLine.Parser.DefaultExitCodeFail);
38+
Environment.Exit(Parser.DefaultExitCodeFail);
3939

40-
var plugin = plugins.FirstOrDefault(x => x.Name == options.PlugInName);
40+
var plugin = plugins.FirstOrDefault(x => x.Name == options.PluginName);
4141
if (plugin == null)
42-
ExitWithFailure("Plugin does not exist: " + options.PlugInName);
42+
ExitWithFailure("Plugin does not exist: " + options.PluginName);
4343

4444
var pluginOptionList = plugin.MakeOptions();
4545

4646
var pluginArgs = args.Skip(1).ToArray();
4747
if (!pluginArgs.ToList().Any()) {
4848
// If the plugin's args are empty, print the plugin's help screen and exit.
4949
foreach(var pluginOptions in pluginOptionList) {
50-
CommandLine.Parser.Default.ParseArguments(pluginArgs, pluginOptions);
50+
Parser.Default.ParseArguments(pluginArgs, pluginOptions);
5151
Console.WriteLine(pluginOptions.GetUsage(""));
5252
}
5353
ExitWithSuccess();
@@ -72,16 +72,22 @@ public void ExitWithSuccess(string message = null)
7272

7373
public void ExitWithFailure(string message = null)
7474
{
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);
7977
}
8078

8179
public void ExitWithFailure(Exception exception = null)
8280
{
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}";
8591
}
8692

8793
public List<Plugin> FindPlugins()
@@ -96,8 +102,7 @@ public List<Plugin> FindPlugins()
96102

97103
public void InterpretPluginArguments(string[] pluginArgs, IOptions pluginOptions)
98104
{
99-
var isSuccessful = CommandLine
100-
.Parser
105+
var isSuccessful = Parser
101106
.Default
102107
.ParseArguments(pluginArgs, pluginOptions, (verb, subOptions) =>
103108
{

src/InEngineCli/NLog.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
</targets>
1212

1313
<rules>
14-
<logger name="*" minlevel="Debug" writeTo="c" />
14+
<logger name="*" minlevel="Trace" writeTo="c" />
1515
</rules>
1616
</nlog>

src/InEngineCli/Options.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace InEngineCli
88
public class Options
99
{
1010
[Option('p', "plugin", Required = true, HelpText = "Plug-In to activate.", DefaultValue = "InEngine.Core")]
11-
public string PlugInName { get; set; }
11+
public string PluginName { get; set; }
1212

1313
[HelpVerbOption]
1414
public string GetUsage(string verb)

0 commit comments

Comments
 (0)