auto builder = new HelpTextBuilderSimple(); builder.addPositionalArg(0, "The input file.", ArgIsOptional.no, "InputFile") .addPositionalArg(1, "The output file.", ArgIsOptional.no, "OutputFile") .addPositionalArg("Utility", 2, "How much to compress the file.", ArgIsOptional.no, "CompressionLevel") .addNamedArg(["v","verbose"], "Verbose output", ArgIsOptional.yes) .addNamedArg("Utility", "encoding", "Sets the encoding to use.", ArgIsOptional.yes) .setCommandName("MyCommand") .setDescription("This is a command that transforms the InputFile into an OutputFile") .setGroupDescription("Utility", "Utility arguments used to modify the output."); assert(builder.toString() == "Usage: MyCommand <InputFile> <OutputFile> <CompressionLevel> [-v|--verbose] [--encoding] \n" ~"\n" ~"Description:\n" ~" This is a command that transforms the InputFile into an OutputFile\n" ~"\n" ~"Positional Args:\n" ~" InputFile - The input file.\n" ~" OutputFile - The output file.\n" ~"\n" ~"Named Args:\n" ~" -v,--verbose - Verbose output\n" ~"\n" ~"Utility:\n" ~" Utility arguments used to modify the output.\n" ~"\n" ~" CompressionLevel - How much to compress the file.\n" ~" --encoding - Sets the encoding to use.", "\n"~builder.toString() );
A simpler version of HelpTextBuilerTechnical, as it has a fixed layout, and handles all of the section and content generation.
Description: This help text builder contains the following:
* A single 'Usage' line, which is generated automatically from the rest of the given data. * A description section. * A section for positional parameters, which are given a position, description, and an optional display name. * A section for named parameters, which can have multiple names, and a description.
Please see the unittest for an example of its usage and output.