NTP Analyzer
0.8.2
Analyze the operation of time servers
|
Classes | |
class | ArgumentSource |
class | DirectoryCommand |
class | Option |
class | OptionContext |
class | OptionException |
class | OptionSet |
class | OptionValueCollection |
class | Permission |
class | ResponseFileSource |
class | ShellCommand |
class | StringCoda |
Enumerations | |
enum | OptionValueType { OptionValueType.None, OptionValueType.Optional, OptionValueType.Required } |
Functions | |
delegate void | OptionAction< in TKey, in TValue > (TKey key, TValue value) |
Authors: Jonathan Pryor jpryo Federico Di Gregorio r@no vell. comfog@i Rolf Bjarne Kvinge nitd .orgrolf@ xama rin.c om
Copyright (C) 2008 Novell (http://www.novell.com) Copyright (C) 2009 Federico Di Gregorio. Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Compile With: gmcs -debug+ -r:System.Core Options.cs -o:NDesk.Options.dll gmcs -debug+ -d:LINQ -r:System.Core Options.cs -o:NDesk.Options.dll
The LINQ version just changes the implementation of OptionSet.Parse(IEnumerable<string>), and confers no semantic changes.
A Getopt::Long-inspired option parsing library for C#.
NDesk.Options.OptionSet is built upon a key/value table, where the key is a option format string and the value is a delegate that is invoked when the format string is matched.
Option format strings: Regex-like BNF Grammar: name: .+ type: [=:] sep: ( [^{}]+ | '{' .+ '}' )? aliases: ( name type sep ) ( '|' name type sep )*
Each '|'-delimited name is an alias for the associated action. If the format string ends in a '=', it has a required value. If the format string ends in a ':', it has an optional value. If neither '=' or ':' is present, no value is supported. `=' or `:' need only be defined on one alias, but if they are provided on more than one they must be consistent.
Each alias portion may also end with a "key/value separator", which is used to split option values if the option accepts > 1 value. If not specified, it defaults to '=' and ':'. If specified, it can be any character except '{' and '}' OR the string between '{' and '}'. If no separator should be used (i.e. the separate values should be distinct arguments), then "{}" should be used as the separator.
Options are extracted either from the current option by looking for the option name followed by an '=' or ':', or is taken from the following option IFF:
The `name' used in the option format string does NOT include any leading option indicator, such as '-', '–', or '/'. All three of these are permitted/required on any named option.
Option bundling is permitted so long as:
This allows specifying '-a -b -c' as '-abc', and specifying '-D name=value' as '-Dname=value'.
Option processing is disabled by specifying "--". All options after "--" are returned by OptionSet.Parse() unchanged and unprocessed.
Unprocessed options are returned from OptionSet.Parse().
Examples: int verbose = 0; OptionSet p = new OptionSet () .Add ("v", v => ++verbose) .Add ("name=|value=", v => Console.WriteLine (v)); p.Parse (new string[]{"-v", "--v", "/v", "-name=A", "/name", "B", "extra"});
The above would parse the argument string array, and would invoke the lambda expression three times, setting `verbose' to 3 when complete. It would also print out "A" and "B" to standard output. The returned array would contain the string "extra".
C# 3.0 collection initializers are supported and encouraged: var p = new OptionSet () { { "h|?|help", v => ShowHelp () }, };
System.ComponentModel.TypeConverter is also supported, allowing the use of custom data types in the callback type; TypeConverter.ConvertFromString() is used to convert the value option to an instance of the specified type:
var p = new OptionSet () { { "foo=", (Foo f) => Console.WriteLine (f.ToString ()) }, };
Random other tidbits:
|
strong |
Enumerator | |
---|---|
None | |
Optional | |
Required |
Definition at line 443 of file Options.cs.
delegate void Ntp.Common.IO.OptionAction< in TKey, in TValue > | ( | TKey | key, |
TValue | value | ||
) |
Referenced by Ntp.Common.IO.OptionException.GetObjectData().