[Mono.Options] Improve error message for badly bundled args.
authorJonathan Pryor <jonpryor@vt.edu>
Thu, 5 Dec 2013 20:39:05 +0000 (15:39 -0500)
committerJonathan Pryor <jonpryor@vt.edu>
Thu, 5 Dec 2013 20:43:35 +0000 (15:43 -0500)
commita699e7444e8ff4426197d4bd3a9607d204ee7b0f
treeb0f8b98417ce4c130bd8acc9b60459a13cd13545
parent37e3c51b13ccfc964103ae2bcfe7a5aeb7008bd7
[Mono.Options] Improve error message for badly bundled args.

mono(1) supports a "joined" verbose flag, `mono -v-v-v-v`, which
Mono.Options doesn't support. Attempting to use it, however, resulted
in a "weird" error message:

$ csharp -r:Mono.Options.dll
csharp> using Mono.Options;
csharp> var p = new OptionSet { { "v", v => {} } };
csharp> p.Parse (new[]{"-v-v-v"});
Mono.Options.OptionException: Cannot bundle unregistered option '--'.
...

This looks very weird to users because they never used a "--" option,
and if they had then `--` would have disabled further option
processing (as documented and implemented in OptionSet.Parse()).

Confusion all around.

Improve the error message so that it instead generates:

Mono.Options.OptionException: Cannot use unregistered option '-' in bundle '-v-v-v'.

That way the user gets the full context of where this "unregistered
option" came from.
mcs/class/Mono.Options/Mono.Options/Options.cs
mcs/class/Mono.Options/Test/Mono.Options/OptionSetTest.cs