Skip to content

Latest commit

 

History

History
94 lines (63 loc) · 6.83 KB

File metadata and controls

94 lines (63 loc) · 6.83 KB

9.3. Include directives

Six section names (include directives) are supported in the help files, and one (@All) in the usage files. These are introduced with the ARGPARSER_HELP_FILE_INCLUDE_CHAR or ARGPARSER_USAGE_FILE_INCLUDE_CHAR, respectively, defaulting to "@".

Table of contents (Include directives)

  1. @All directive
  2. @<ArgumentGroup> directive
  3. @Description directive
  4. @Header directive
  5. @Help directive
  6. @Remark directive
  7. @Usage directive

9.3.1. @All directive

For help messages, the @All directive comprises all include directives in the following order: @Usage, @Description, @Remark, @<ArgumentGroup>, and @@Help, separated from each other by a blank line.

Consequently, the help message generated from the ARGPARSER_HELP_FILE with the following content:

@All

is exactly identical to the one from the following content (note the blank lines):

@Usage

@Description

@Remark

@<ArgumentGroup>

@@Help

When not using help or usage files, the Argparser internally uses the @All include directive, and thus generates an identical help message.

For usage messages, @All prints the usual usage message, which currently isn't subdivided into distinct include directives.

9.3.2. @<ArgumentGroup> directive

The @<ArgumentGroup> directive prints the help message block for the respective "<ArgumentGroup>", like "Mandatory options" for the include directive @Mandatory options or "Optional options" for the include directive @Optional options.

Their order in the auto-generated help message would be alphabetical for the keyword arguments, preceded by the group for the positional arguments (the ARGPARSER_POSITIONAL_ARG_GROUP) and succeeded by the help options group (the ARGPARSER_HELP_ARG_GROUP). Thus, if you have reasons for another structure, you need an ARGPARSER_HELP_FILE, denoting all arguments groups in the order preferred by you.

By using one ARGPARSER_HELP_FILE_INCLUDE_CHAR, the arguments group's arguments are preceded by the group's name as section heading. You can double the include character to suppress this addition.

9.3.3. @Description directive

The @Description directive prints the contents of ARGPARSER_HELP_DESCRIPTION, wrapped to fit ARGPARSER_MAX_WIDTH. If ARGPARSER_HELP_DESCRIPTION is empty (the default), nothing is printed.

9.3.4. @Header directive

The @Header directive comprises the @Usage, @Description and @Remark include directive, separated from each other by a blank line, and is thus the shorthand for including all three.

9.3.5. @Help directive

The @Help directive prints the help text for the --help, --usage, and --version flags (if added to the arguments definition by ARGPARSER_ADD_HELP, ARGPARSER_ADD_USAGE, or ARGPARSER_ADD_VERSION). Usually, you want to give this at the very end of all options. Again, you can suppress the ARGPARSER_HELP_ARG_GROUP heading by doubling the ARGPARSER_HELP_FILE_INCLUDE_CHAR, which is also the default behaviour within the @All include directive (and thus the default when not using help files).

9.3.6. @Remark directive

The @Remark directive prints the note that mandatory arguments to long options are mandatory for short options too, wrapped to fit ARGPARSER_MAX_WIDTH. This should be given just before all arguments.

9.3.7. @Usage directive

The @Usage directive prints the line Usage: <script_name> ..., with <script_name> replaced by ARGPARSER_SCRIPT_NAME, defaulting to your script's name. This should be given as first line.

🡄 9.2. Colors and styles           9.4. Environment variables 🡆