|
| OptionSet () |
|
| OptionSet (MessageLocalizerConverter localizer) |
|
OptionSet | Add (string header) |
|
new OptionSet | Add (Option option) |
|
OptionSet | Add (string prototype, Action< string > action) |
|
OptionSet | Add (string prototype, string description, Action< string > action) |
|
OptionSet | Add (string prototype, string description, Action< string > action, bool hidden) |
|
OptionSet | Add (string prototype, OptionAction< string, string > action) |
|
OptionSet | Add (string prototype, string description, OptionAction< string, string > action) |
|
OptionSet | Add (string prototype, string description, OptionAction< string, string > action, bool hidden) |
|
OptionSet | Add (ArgumentSource source) |
|
OptionSet | Add< T > (string prototype, Action< T > action) |
|
OptionSet | Add< T > (string prototype, string description, Action< T > action) |
|
OptionSet | Add< TKey, TValue > (string prototype, OptionAction< TKey, TValue > action) |
|
OptionSet | Add< TKey, TValue > (string prototype, string description, OptionAction< TKey, TValue > action) |
|
List< string > | Parse (IEnumerable< string > arguments) |
|
void | WriteOptionDescriptions (TextWriter o) |
|
|
void | AddImpl (Option option) |
|
bool | AddSource (ArgumentEnumerator ae, string argument) |
|
bool | ParseBool (string option, string n, OptionContext c) |
|
bool | ParseBundledValue (string f, string n, OptionContext c) |
|
void | ParseValue (string option, OptionContext c) |
|
void | WriteDescription (TextWriter o, string value, string prefix, int firstWidth, int remWidth) |
|
bool | WriteOptionPrototype (TextWriter o, Option p, ref int written) |
|
|
static string | GetArgumentName (int index, int maxIndex, string description) |
|
static string | GetDescription (string description) |
|
static IEnumerable< string > | GetLines (string description, int firstWidth, int remWidth) |
|
static int | GetNextOptionIndex (string[] names, int i) |
|
static void | Invoke (OptionContext c, string name, string value, Option option) |
|
static void | Unprocessed (ICollection< string > extra, Option def, OptionContext c, string argument) |
|
static void | Write (TextWriter o, ref int n, string s) |
|
Definition at line 785 of file Options.cs.
Ntp.Common.IO.OptionSet.OptionSet |
( |
| ) |
|
|
inline |
Definition at line 792 of file Options.cs.
ReadOnlyCollection< ArgumentSource > ArgumentSources
readonly List< ArgumentSource > sources
MessageLocalizerConverter MessageLocalizer
OptionSet Ntp.Common.IO.OptionSet.Add |
( |
string |
header | ) |
|
|
inline |
OptionSet Ntp.Common.IO.OptionSet.Add |
( |
string |
prototype, |
|
|
Action< string > |
action |
|
) |
| |
|
inline |
Definition at line 826 of file Options.cs.
828 return Add(prototype, null, action);
OptionSet Add(string header)
OptionSet Ntp.Common.IO.OptionSet.Add |
( |
string |
prototype, |
|
|
string |
description, |
|
|
Action< string > |
action |
|
) |
| |
|
inline |
Definition at line 831 of file Options.cs.
833 return Add(prototype, description, action,
false);
OptionSet Add(string header)
OptionSet Ntp.Common.IO.OptionSet.Add |
( |
string |
prototype, |
|
|
string |
description, |
|
|
Action< string > |
action, |
|
|
bool |
hidden |
|
) |
| |
|
inline |
Definition at line 836 of file Options.cs.
839 throw new ArgumentNullException(nameof(action));
840 Option p =
new ActionOption(prototype, description, 1,
841 delegate(OptionValueCollection v) { action(v[0]); }, hidden);
OptionSet Ntp.Common.IO.OptionSet.Add |
( |
string |
prototype, |
|
|
OptionAction< string, string > |
action |
|
) |
| |
|
inline |
Definition at line 846 of file Options.cs.
848 return Add(prototype, null, action);
OptionSet Add(string header)
OptionSet Ntp.Common.IO.OptionSet.Add |
( |
string |
prototype, |
|
|
string |
description, |
|
|
OptionAction< string, string > |
action |
|
) |
| |
|
inline |
Definition at line 851 of file Options.cs.
853 return Add(prototype, description, action,
false);
OptionSet Add(string header)
OptionSet Ntp.Common.IO.OptionSet.Add |
( |
string |
prototype, |
|
|
string |
description, |
|
|
OptionAction< string, string > |
action, |
|
|
bool |
hidden |
|
) |
| |
|
inline |
Definition at line 856 of file Options.cs.
859 throw new ArgumentNullException(nameof(action));
860 Option p =
new ActionOption(prototype, description, 2,
861 delegate(OptionValueCollection v) { action(v[0], v[1]); }, hidden);
Definition at line 886 of file Options.cs.
889 throw new ArgumentNullException(nameof(source));
readonly List< ArgumentSource > sources
Definition at line 866 of file Options.cs.
868 return Add(prototype, null, action);
OptionSet Add(string header)
Definition at line 871 of file Options.cs.
873 return Add(
new ActionOption<T>(prototype, description, action));
OptionSet Add(string header)
Definition at line 876 of file Options.cs.
878 return Add(prototype, null, action);
OptionSet Add(string header)
Definition at line 881 of file Options.cs.
883 return Add(
new ActionOption<TKey, TValue>(prototype, description, action));
OptionSet Add(string header)
void Ntp.Common.IO.OptionSet.AddImpl |
( |
Option |
option | ) |
|
|
inlineprivate |
Definition at line 1101 of file Options.cs.
References Ntp.Common.IO.Option.Names.
1104 throw new ArgumentNullException(nameof(option));
1105 var added =
new List<string>(option.Names.Length);
1109 for (var i = 1; i < option.Names.Length; ++i)
1111 Dictionary.Add(option.Names[i], option);
1112 added.Add(option.Names[i]);
1117 foreach (var name
in added)
1118 Dictionary.Remove(name);
Definition at line 1123 of file Options.cs.
1125 foreach (var source
in sources)
1127 IEnumerable<string> replacement;
1128 if (!source.GetArguments(argument, out replacement))
1130 ae.Add(replacement);
readonly List< ArgumentSource > sources
virtual OptionContext Ntp.Common.IO.OptionSet.CreateOptionContext |
( |
| ) |
|
|
inlineprotectedvirtual |
Definition at line 989 of file Options.cs.
991 return new OptionContext(
this);
static string Ntp.Common.IO.OptionSet.GetArgumentName |
( |
int |
index, |
|
|
int |
maxIndex, |
|
|
string |
description |
|
) |
| |
|
inlinestaticprivate |
Definition at line 1136 of file Options.cs.
1138 if (description == null)
1139 return maxIndex == 1 ?
"VALUE" :
"VALUE" + (index + 1);
1141 var nameStart = maxIndex == 1 ?
new[] {
"{0:",
"{"} :
new[] {
"{" + index +
":"};
1143 foreach (var t
in nameStart)
1148 start = description.IndexOf(t, j, StringComparison.Ordinal);
1149 }
while (start >= 0 && j != 0 && description[j++ - 1] ==
'{');
1152 var end = description.IndexOf(
"}", start, StringComparison.Ordinal);
1155 return description.Substring(start + t.Length, end - start - t.Length);
1158 return maxIndex == 1 ?
"VALUE" :
"VALUE" + (index + 1);
static string Ntp.Common.IO.OptionSet.GetDescription |
( |
string |
description | ) |
|
|
inlinestaticprivate |
Definition at line 1161 of file Options.cs.
1163 if (description == null)
1164 return string.Empty;
1165 var sb =
new StringBuilder(description.Length);
1167 for (var i = 0; i < description.Length; ++i)
1169 switch (description[i])
1183 if (i + 1 == description.Length || description[i + 1] !=
'}')
1184 throw new InvalidOperationException(
"Invalid option description: " + description);
1190 sb.Append(description.Substring(start, i - start));
1201 sb.Append(description[i]);
1205 return sb.ToString();
override string Ntp.Common.IO.OptionSet.GetKeyForItem |
( |
Option |
item | ) |
|
|
inlineprotected |
Definition at line 995 of file Options.cs.
References Ntp.Common.IO.Option.Names.
998 throw new ArgumentNullException(nameof(item));
999 if (item.Names != null && item.Names.Length > 0)
1000 return item.Names[0];
1003 throw new InvalidOperationException(
"Option has no names!");
static IEnumerable<string> Ntp.Common.IO.OptionSet.GetLines |
( |
string |
description, |
|
|
int |
firstWidth, |
|
|
int |
remWidth |
|
) |
| |
|
inlinestaticprivate |
static int Ntp.Common.IO.OptionSet.GetNextOptionIndex |
( |
string[] |
names, |
|
|
int |
i |
|
) |
| |
|
inlinestaticprivate |
Definition at line 1213 of file Options.cs.
1215 while (i < names.Length && names[i] ==
"<>")
Option Ntp.Common.IO.OptionSet.GetOptionForName |
( |
string |
option | ) |
|
|
inlineprotected |
Definition at line 1007 of file Options.cs.
1010 throw new ArgumentNullException(nameof(option));
1013 return base[option];
1015 catch (KeyNotFoundException)
bool Ntp.Common.IO.OptionSet.GetOptionParts |
( |
string |
argument, |
|
|
out string |
flag, |
|
|
out string |
name, |
|
|
out string |
sep, |
|
|
out string |
value |
|
) |
| |
|
inlineprotected |
Definition at line 1021 of file Options.cs.
1024 if (argument == null)
1025 throw new ArgumentNullException(nameof(argument));
1027 flag = name = sep = value = null;
1033 flag = m.Groups[
"flag"].Value;
1034 name = m.Groups[
"name"].Value;
1035 if (m.Groups[
"sep"].Success && m.Groups[
"value"].Success)
1037 sep = m.Groups[
"sep"].Value;
1038 value = m.Groups[
"value"].Value;
readonly Regex valueOption
override void Ntp.Common.IO.OptionSet.InsertItem |
( |
int |
index, |
|
|
Option |
item |
|
) |
| |
|
inlineprotected |
Definition at line 1043 of file Options.cs.
1045 base.InsertItem(index, item);
void AddImpl(Option option)
static void Ntp.Common.IO.OptionSet.Invoke |
( |
OptionContext |
c, |
|
|
string |
name, |
|
|
string |
value, |
|
|
Option |
option |
|
) |
| |
|
inlinestaticprivate |
List<string> Ntp.Common.IO.OptionSet.Parse |
( |
IEnumerable< string > |
arguments | ) |
|
|
inline |
Definition at line 894 of file Options.cs.
896 if (arguments == null)
897 throw new ArgumentNullException(nameof(arguments));
902 var unprocessed =
new List<string>();
903 var def = Contains(
"<>") ?
this[
"<>"] : null;
904 var ae =
new ArgumentEnumerator(arguments);
906 foreach (var argument
in ae)
909 if (argument ==
"--")
921 if (!
Parse(argument, c))
static void Unprocessed(ICollection< string > extra, Option def, OptionContext c, string argument)
virtual OptionContext CreateOptionContext()
bool AddSource(ArgumentEnumerator ae, string argument)
List< string > Parse(IEnumerable< string > arguments)
virtual bool Ntp.Common.IO.OptionSet.Parse |
( |
string |
argument, |
|
|
OptionContext |
c |
|
) |
| |
|
inlineprotectedvirtual |
Definition at line 1049 of file Options.cs.
References Ntp.Common.IO.OptionValueCollection.Add(), Ntp.Common.IO.Option.Invoke(), Ntp.Common.IO.OptionContext.Option, Ntp.Common.IO.OptionContext.OptionName, Ntp.Common.IO.OptionContext.OptionValues, and s().
1051 if (
c.Option != null)
1064 c.OptionName = f + n;
1066 switch (p.OptionValueType)
1069 c.OptionValues.Add(n);
bool ParseBool(string option, string n, OptionContext c)
bool GetOptionParts(string argument, out string flag, out string name, out string sep, out string value)
bool ParseBundledValue(string f, string n, OptionContext c)
void ParseValue(string option, OptionContext c)
bool Ntp.Common.IO.OptionSet.ParseBool |
( |
string |
option, |
|
|
string |
n, |
|
|
OptionContext |
c |
|
) |
| |
|
inlineprivate |
bool Ntp.Common.IO.OptionSet.ParseBundledValue |
( |
string |
f, |
|
|
string |
n, |
|
|
OptionContext |
c |
|
) |
| |
|
inlineprivate |
Definition at line 1247 of file Options.cs.
References Ntp.Common.IO.OptionContext.Option, and Ntp.Common.IO.OptionContext.OptionName.
1251 for (var i = 0; i < n.Length; ++i)
1254 var rn = n[i].ToString();
1260 "Cannot use unregistered option '{0}' in bundle '{1}'."), rn, f + n), null);
1263 switch (p.OptionValueType)
1271 var v = n.Substring(i + 1);
1278 throw new InvalidOperationException(
"Unknown OptionValueType: " + p.OptionValueType);
static void Invoke(OptionContext c, string name, string value, Option option)
MessageLocalizerConverter MessageLocalizer
void ParseValue(string option, OptionContext c)
void Ntp.Common.IO.OptionSet.ParseValue |
( |
string |
option, |
|
|
OptionContext |
c |
|
) |
| |
|
inlineprivate |
Definition at line 1284 of file Options.cs.
1287 foreach (var o
in c.Option.ValueSeparators != null
1288 ? option.Split(
c.Option.ValueSeparators,
c.Option.MaxValueCount -
c.OptionValues.Count,
1289 StringSplitOptions.None)
1292 c.OptionValues.Add(o);
1294 if (
c.OptionValues.Count ==
c.Option.MaxValueCount ||
1297 else if (
c.OptionValues.Count >
c.Option.MaxValueCount)
1300 $
"Error: Found {c.OptionValues.Count} option values when expecting {c.Option.MaxValueCount}."),
MessageLocalizerConverter MessageLocalizer
override void Ntp.Common.IO.OptionSet.RemoveItem |
( |
int |
index | ) |
|
|
inlineprotected |
Definition at line 1084 of file Options.cs.
1086 var p = Items[index];
1087 base.RemoveItem(index);
1089 for (var i = 1; i < p.Names.Length; ++i)
1091 Dictionary.Remove(p.Names[i]);
override void Ntp.Common.IO.OptionSet.SetItem |
( |
int |
index, |
|
|
Option |
item |
|
) |
| |
|
inlineprotected |
Definition at line 1095 of file Options.cs.
1097 base.SetItem(index, item);
void AddImpl(Option option)
static void Ntp.Common.IO.OptionSet.Unprocessed |
( |
ICollection< string > |
extra, |
|
|
Option |
def, |
|
|
OptionContext |
c, |
|
|
string |
argument |
|
) |
| |
|
inlinestaticprivate |
static void Ntp.Common.IO.OptionSet.Write |
( |
TextWriter |
o, |
|
|
ref int |
n, |
|
|
string |
s |
|
) |
| |
|
inlinestaticprivate |
void Ntp.Common.IO.OptionSet.WriteDescription |
( |
TextWriter |
o, |
|
|
string |
value, |
|
|
string |
prefix, |
|
|
int |
firstWidth, |
|
|
int |
remWidth |
|
) |
| |
|
inlineprivate |
Definition at line 1323 of file Options.cs.
static string GetDescription(string description)
static IEnumerable< string > GetLines(string description, int firstWidth, int remWidth)
MessageLocalizerConverter MessageLocalizer
void Ntp.Common.IO.OptionSet.WriteOptionDescriptions |
( |
TextWriter |
o | ) |
|
|
inline |
Definition at line 929 of file Options.cs.
References s().
931 foreach (var p
in this)
938 var
c = p as Category;
962 var names = s.GetNames();
963 if (names == null || names.Length == 0)
968 Write(o, ref written,
" ");
969 Write(o, ref written, names[0]);
970 for (var i = 1; i < names.Length; ++i)
972 Write(o, ref written,
", ");
973 Write(o, ref written, names[i]);
const int DescriptionRemWidth
bool WriteOptionPrototype(TextWriter o, Option p, ref int written)
static void Write(TextWriter o, ref int n, string s)
void WriteDescription(TextWriter o, string value, string prefix, int firstWidth, int remWidth)
const int DescriptionFirstWidth
readonly List< ArgumentSource > sources
bool Ntp.Common.IO.OptionSet.WriteOptionPrototype |
( |
TextWriter |
o, |
|
|
Option |
p, |
|
|
ref int |
written |
|
) |
| |
|
inlineprivate |
Definition at line 1335 of file Options.cs.
References c, Ntp.Common.IO.Option.Description, Ntp.Common.IO.Option.MaxValueCount, Ntp.Common.IO.Option.Names, Ntp.Common.IO.Option.OptionValueType, and Ntp.Common.IO.Option.ValueSeparators.
1337 var names = p.Names;
1340 if (i == names.Length)
1343 if (names[i].Length == 1)
1345 Write(o, ref written,
" -");
1346 Write(o, ref written, names[0]);
1350 Write(o, ref written,
" --");
1351 Write(o, ref written, names[0]);
1358 Write(o, ref written,
", ");
1359 Write(o, ref written, names[i].Length == 1 ?
"-" :
"--");
1360 Write(o, ref written, names[i]);
1371 var sep = p.ValueSeparators != null && p.ValueSeparators.Length > 0
1372 ? p.ValueSeparators[0]
1374 for (var
c = 1;
c < p.MaxValueCount; ++
c)
static int GetNextOptionIndex(string[] names, int i)
static string GetArgumentName(int index, int maxIndex, string description)
static void Write(TextWriter o, ref int n, string s)
MessageLocalizerConverter MessageLocalizer
const int Ntp.Common.IO.OptionSet.DescriptionFirstWidth = 80 - OptionWidth |
|
private |
const int Ntp.Common.IO.OptionSet.DescriptionRemWidth = 80 - OptionWidth - 2 |
|
private |
const int Ntp.Common.IO.OptionSet.OptionWidth = 29 |
|
private |
readonly Regex Ntp.Common.IO.OptionSet.valueOption |
|
private |
Initial value:= new Regex(
@"^(?<flag>--|-|/)(?<name>[^:=]+)((?<sep>[:=])(?<value>.*))?$")
Definition at line 804 of file Options.cs.
ReadOnlyCollection<ArgumentSource> Ntp.Common.IO.OptionSet.ArgumentSources |
|
get |
The documentation for this class was generated from the following file: