Skip to content

Commit dc6cfc4

Browse files
committed
Update the handling of an unknown option
The default `<>` `OptionSet` would "consume" the remaining fields. So instead check the remaining parts and when they look as option and are not existing file, report an error.
1 parent 3b825e6 commit dc6cfc4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Program.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,18 @@ public static void Main (string [] args)
6969
{ "v|verbose",
7070
"Output information about progress during the run of the tool",
7171
v => Verbose = true },
72-
{ "<>",
73-
v => { Error ($"Unknown option: {v}"); help = true; helpExitCode = 99; } },
7472
};
7573

7674
var remaining = options.Parse (args);
7775

76+
foreach (var s in remaining) {
77+
if (s.Length > 0 && (s [0] == '-' || s [0] == '/') && !File.Exists (s)) {
78+
Error ($"Unknown option: {s}");
79+
help = true;
80+
helpExitCode = 99;
81+
}
82+
}
83+
7884
if (help || args.Length < 1) {
7985
options.WriteOptionDescriptions (Out);
8086

0 commit comments

Comments
 (0)