Options

How Options become Properties become Parameters

An Option is a tag-value (or name-value) token that is parsed from the command-line:

--filename=Input.xml --out='outDir\' --forceOverride

An Option without an explicit value is resolved to boolean: true like --forceOverride in the example above.

For each Option provided in the command-line the Commander tries to find an appropriate OptionDescriptor. OptionDescriptors are automatically resolved by searching for the corresponding Annotations, or they can be added manually to the Commander(see How Commander uses Annotations) .

An OptionDescriptor describes an Option. An OptionDescriptor determines if an Option is required, the recognized Option names and tokens, its data type, the help text and its static default value.

A group of options is called Parameters class which is finally passed to a Command.

class XmlConverterParameters
{
    [OptionDescriptor("filename", "f", Required = true)]
    public string Filename { get; set; }

    [OptionDescriptor("out", "o", Required = false, Default = "out")]
    public string OutDir  { get; set; }

    [OptionDescriptor("forceOverride", "fo", 
                      Required = false, Default = true)]
    public bool ForceOverride { get; set; }
}

__Parameters classes do not need annotations. A Parameters class simply acts as a container for all Options which belong to a Command. The Properties in a Parameters class take the Option values from command-line.

Last updated