Command Line Parser Library
Apparence
Documentation
Options
// créer une classe dont l'instance sera passée à la méthode ParseArguments
class Options
{
[Usage(ApplicationAlias = "My Application")]
public static IEnumerable<Example> Examples => new List<Example>()
{
new Example(
"Description of the application",
new Options { Option1 = "Option1", Option2 = 100 })
};
[Option('o', "option1", Required = true, HelpText = "Option1.")]
public string Option1 { get; set; }
[Option('t', "option2", HelpText = "Option2.")]
public int Option2 { get; set; }
}
|
Parse
var options = new Options();
if (CommandLine.Parser.Default.ParseArguments(args, options))
{
if (options.Verbose) { }
var inputDirectory = options.InputDirectory;
if (options.OptionsList != null && options.OptionsList.Contains("mon_option")) { }
}
|
Command line
![]() |
By default options --help and --version are available. |
![]() |
In case of missing or unknown argument or parsing error, the errors are displayed with the usage explanation message and the application exits. |
# option1
-o value
-ovalue
--option1 value
--option1=value
|