HelpTextBuilderSimple

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.

Members

Functions

addNamedArg
HelpTextBuilderSimple addNamedArg(string group, string[] names, string description, ArgIsOptional isOptional)
addNamedArg
HelpTextBuilderSimple addNamedArg(string group, string name, string description, ArgIsOptional isOptional)
addNamedArg
HelpTextBuilderSimple addNamedArg(string[] names, string description, ArgIsOptional isOptional)
addNamedArg
HelpTextBuilderSimple addNamedArg(string name, string description, ArgIsOptional isOptional)
addPositionalArg
HelpTextBuilderSimple addPositionalArg(string group, size_t position, string description, ArgIsOptional isOptional, string displayName)
addPositionalArg
HelpTextBuilderSimple addPositionalArg(size_t position, string description, ArgIsOptional isOptional, string displayName)
setCommandName
HelpTextBuilderSimple setCommandName(string name)
setDescription
HelpTextBuilderSimple setDescription(string desc)
setGroupDescription
HelpTextBuilderSimple setGroupDescription(string group, string description)
toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

commandName
string commandName [@property getter]
description
string description [@property getter]

Examples

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()
);

Meta