[Mono.Options] Add option header support.
Option headers can be provided via OptionSet.Add(string), and allows
forgoing the use of a separate mechanism to provide contextual output.
For example, one used to do this:
bool show_help = false;
new OptionSet {
// ...
{ "help|h|?", v => show_help = v != null },
}.Parse (args);
if (show_help) {
Console.WriteLine ("usage: sample-app ARGS");
p.WriteOptionDescriptions (Console.Out);
// ...
}
Using the new header support, the "contextual" output can be merged
with the option specification:
bool show_help = false;
new OptionSet {
"usage: sample-app ARGS",
{ "help|h|?", v => show_help = v != null },
}.Parse (args);
if (show_help)
p.WriteOptionDescriptions (Console.Out);
Furthermore, headers can be provided "inline", thus serving as a
mechanism to categorize options:
// mcs options
var p = new OptionSet {
"Mono C# compiler, Copyright 2001 - 2011 Novell, Inc.",
"mcs [options] source-files",
// ...
"Resources:",
{ "linkresource|linkres:", v => /* ... */ },
// ...
"",
"Options can be of the form -option or /option",
};
17 files changed: