diff options
author | Jonathan Pryor <jonpryor@vt.edu> | 2011-03-07 03:30:48 +0300 |
---|---|---|
committer | Jonathan Pryor <jonpryor@vt.edu> | 2011-03-07 09:59:44 +0300 |
commit | 419ce873554e652485b4f7a3c82ed7ac5430c609 (patch) | |
tree | 486eb4dc3b90db3100cb433fc5d9858ec1a18049 /data | |
parent | 816fb2e0ff24770267de0b6eaaac5eb57b0203ff (diff) |
[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",
};
Diffstat (limited to 'data')
-rw-r--r-- | data/mono-options.pc.in | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/data/mono-options.pc.in b/data/mono-options.pc.in index 8c569820d4e..8569ffc2efb 100644 --- a/data/mono-options.pc.in +++ b/data/mono-options.pc.in @@ -4,4 +4,4 @@ Sources=${assemblies_dir}/Options.cs Name: Mono.Options Description: Command Line Parsing Library -Version: 0.2.2 +Version: 0.2.3 |