Add support for multicharacter short option
Sometime it is usefull to have not only single char short option like [Option('d', "download-file")] but something like [Option('gf', "graph-file")].
This is not a common approach, but might be needed for compatibility of command line parameters with other products.
I'm in favor of this as well. Just a side note though, it would probably be more like [Option("gf", "graph-file")] as C-like languages use single quotes for the char type which can only take one character unless an array is used.
This is not going to happen with short options - short options must be a single character only. This conforms to the standard UNIX getopt format. commandline also allows bundling of short options so -gf is functionally equivalent to -g -f. What are your thoughts on an alias for long options (so --graph-file and --gf are equivalent)?
Example of short arg bundling:
void Main()
{
Parser.Default.ParseArguments<Options>("-lgn Arnold".Split())
.WithParsed(o => o.Dump())
.WithNotParsed(e => e.Dump());
}
public class Options
{
[Option('l', "logging")]
public bool Logging { get; set; }
[Option('g', "graphics")]
public bool Graphics { get; set; }
[Option('r', "realtime")]
public bool Realtime { get; set; }
[Option('n', "name")]
public string Name { get; set; }
}
Aliases is also a very handy feature.
Alias would be handy, indeed. it would simplify backward-compatibility for me.