std.argopt

Overview

The argopt package provides the capability of parsing parameter names and values from command line parameter strings.

Command line parameters are passed to a program in the command line and are used to specify the configuration or behavior of the program. For example, a command-line program may have a parameter to specify the name of the file to be processed, or a parameter to specify the database to be used. These parameters are usually parsed and passed to the code of the program so that the program can correctly execute its functions based on these parameters.

Command line parameters are classified into options and non-options based on whether they are prefixed with -.

  • Options: prefixed with -
    • Short options: prefixed with a single - and containing only one character
    • Long options: prefixed with -- and generally containing multiple characters
    • Short-prefix long options: prefixed with a single - but containing multiple characters
    • Short option combinations: prefixed with - and combining multiple short options in any sequence
  • Non-options: not prefixed with -

NOTE

All parameters following a single -- are also considered non-options. For example, in -f -- a -b --cde, a, -b, and --cde are non-options.

API List

Function

NameDescription
parseArgumentsObtains parameters through parsing based on the given input and specifications.

Class

NameDescription
ArgOpt (deprecated)Parses command line parameters and obtains parsing results.

Enums

NameDescription
ArgumentModeSpecifies the parameter mode.
ArgumentSpecSpecifies the parameter specifications.

Struct

NameDescription
ParsedArgumentsSpecifies the parameter parsing result.

Exception

NameDescription
ArgumentParseExceptionSpecifies the exception thrown when a parsing error occurs.