fix #202 by exiting on invalid option

This commit is contained in:
Andrew Stanton-Nurse 2015-11-16 17:39:03 -08:00
parent 06c66638f3
commit 1dbc62866d

View file

@ -30,18 +30,24 @@ Common Commands:
{
// CommandLineApplication is a bit restrictive, so we parse things ourselves here. Individual apps should use CLA.
var verbose = false;
var success = true;
var command = string.Empty;
var lastArg = 0;
for (; lastArg < args.Length; lastArg++)
{
if (IsArg(args[lastArg], "v", "verbose"))
{
verbose = true;
}
else if (IsArg(args[lastArg], "h", "help"))
{
PrintHelp();
return 0;
}
else if (args[lastArg].StartsWith("-"))
{
PrintHelp($"Unknown option: ${args[lastArg]}");
Reporter.Error.WriteLine($"Unknown option: {args[lastArg]}");
success = false;
}
else
{
@ -50,6 +56,10 @@ Common Commands:
break;
}
}
if (!success) {
PrintHelp();
return 1;
}
var appArgs = (lastArg + 1) >= args.Length ? Enumerable.Empty<string>() : args.Skip(lastArg + 1).ToArray();