public static void FluentConditional(string destinationFromConfig, string[] args) { var opt = new ConditionalOptions(); var parser = new CliParser <ConditionalOptions>(opt); switch (destinationFromConfig) { case "file": parser.HasNamedArgument(c => c.Filename) .WithShortName('f'); break; //case "http": default: parser.HasNamedArgument(c => c.Url) .WithShortName('u'); break; } parser.Parse(args); }
public static void DictBackedConfiguration(string[] args) { var opt = new Dictionary <string, string>(); var parser = new CliParser <Dictionary <string, string> >(opt); parser.HasNamedArgument(c => c["name"]) .WithShortName('n'); parser.Parse(args); Console.WriteLine("Parsed Keys:"); foreach (var kv in opt) { Console.WriteLine("\t{0}: {1}", kv.Key, kv.Value); } }
public static void DictBackendMethodConfig(string[] args) { const int key = 1; var opt = new Dictionary <int, object>(); var parser = new CliParser <Dictionary <int, object> >(opt); parser.HasNamedArgument(c => c[key]) .WithShortName('n'); parser.Parse(args); Console.WriteLine("Parsed Keys:"); foreach (var kv in opt) { Console.WriteLine("\t{0}: {1}", kv.Key, kv.Value); } }