fix #202 by exiting on invalid option
This commit is contained in:
parent
06c66638f3
commit
1dbc62866d
1 changed files with 12 additions and 2 deletions
|
@ -30,18 +30,24 @@ Common Commands:
|
||||||
{
|
{
|
||||||
// CommandLineApplication is a bit restrictive, so we parse things ourselves here. Individual apps should use CLA.
|
// CommandLineApplication is a bit restrictive, so we parse things ourselves here. Individual apps should use CLA.
|
||||||
var verbose = false;
|
var verbose = false;
|
||||||
|
var success = true;
|
||||||
var command = string.Empty;
|
var command = string.Empty;
|
||||||
var lastArg = 0;
|
var lastArg = 0;
|
||||||
|
|
||||||
for (; lastArg < args.Length; lastArg++)
|
for (; lastArg < args.Length; lastArg++)
|
||||||
{
|
{
|
||||||
if (IsArg(args[lastArg], "v", "verbose"))
|
if (IsArg(args[lastArg], "v", "verbose"))
|
||||||
{
|
{
|
||||||
verbose = true;
|
verbose = true;
|
||||||
}
|
}
|
||||||
|
else if (IsArg(args[lastArg], "h", "help"))
|
||||||
|
{
|
||||||
|
PrintHelp();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
else if (args[lastArg].StartsWith("-"))
|
else if (args[lastArg].StartsWith("-"))
|
||||||
{
|
{
|
||||||
PrintHelp($"Unknown option: ${args[lastArg]}");
|
Reporter.Error.WriteLine($"Unknown option: {args[lastArg]}");
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -50,6 +56,10 @@ Common Commands:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!success) {
|
||||||
|
PrintHelp();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
var appArgs = (lastArg + 1) >= args.Length ? Enumerable.Empty<string>() : args.Skip(lastArg + 1).ToArray();
|
var appArgs = (lastArg + 1) >= args.Length ? Enumerable.Empty<string>() : args.Skip(lastArg + 1).ToArray();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue