The array of arguments provided in main().
The instance that will contain parsed values.
Optional option formatter.
std.getopt.GetoptException if parsing fails.
struct MyOptions { @ShortName( 'v' ) bool verbose; string optional; this( string optional ) { this.optional = optional; } } void main( string[] args ) { import std.stdio; auto parsed = MyOptions( "some default value" ); args.parseArgs( parsed ); writelfn( "optional value: %s", parsed.optional ); }
Copyright © 2019, Tony J. Hudgins
MIT
Use std.getopt.getopt to parse command-line arguments into a class or struct.
This function takes a reference to an already existing instance of the destination class or struct if manual construction is needed prior to parsing.
The caller can optionally provide an OptionFormatter delegate to format options into a prett-printed string to display on the help screen. If no delegate is provided the default std.getopt.defaultGetoptFormatter function will be used as a fallback.
Automatically prints the help text and exits the process when help is requested.