-
Notifications
You must be signed in to change notification settings - Fork 1
mint.commandline parser
load mint.commandline-parser
This module provides tools to parse the script's command line arguments.
This enum describe the action to apply to a target variable to treat an argument.
| Constant | Value | Description |
|---|---|---|
| Call | 1 |
Uses the call operator of the target variable with the value as parameter. |
| Count | 3 |
Calls the ++ operator of the target variable any time the parameter is found. |
| Flag | 2 |
Sets the value of the target variable to true. |
| Store | 0 |
Stores the value to the target variable. |
This enum describe an argument type.
| Constant | Value | Description |
|---|---|---|
| Option | 0 |
The argument is an option. |
| Positionnal | 1 |
The argument is positionnal. |
This class provides a way to parse the script's command line parameters from a simple description of the expected arguments. It can also generate an help message from the description.
| Modifiers | Member | Description |
|---|---|---|
enum |
Action | This enum describe the action to apply to a target variable to treat an argum... |
const |
addArgument | Adds an option argument to look for while parsing. The name parameter must be... |
const |
addPositionnalArgument | Adds a positionnal argument to look for while parsing. The name parameter mus... |
const |
getScript | Returns the current script's path as an instance of CommandLineParser.System.... |
const |
new | Creates a new parser. |
| onError | Prints the error_message on the error output and exit the program with error ... |
|
const |
parse | Parses the command line arguments given by args. The args parameter must be the ``... |
const |
setDescription | Sets the script's description to description. If provided, the --help argumen... |
const |
setVersion | Sets the script's version to version. If provided, the --version argument is ... |
const |
showHelp | Prints the help message on the printer described by printer. |
const |
showVersion | Prints the version message on the printer described by printer. |
| Modifiers | Member | Description |
|---|---|---|
const |
addInternalArgument | Adds a builtin option argument to look for while parsing. The name parameter ... |
| Modifiers | Member | Description |
|---|---|---|
class |
Argument | This class describe an argument. |
final |
arguments | Internal arguments list. |
final |
description | Internal description value. |
final |
internalArguments | Internal builtin arguments list. |
final |
options | Internal options access. |
final |
positionnalArguments | Internal positionnal arguments list. |
final |
script | Internal script file. |
final |
version | Internal version value. |
This class describe an argument.
| Modifiers | Member | Description |
|---|---|---|
enum |
Type | This enum describe an argument type. |
const |
getAction | Returns the action to apply to the target variable for this argument. |
const |
getDescription | Returns the description message for this argument. |
const |
getHelp | Returns the help message for this argument. |
const |
getParameter | Returns the parameter list for this argument. |
const |
getTarget | Returns the target variable for this argument. |
| name | Argument name(s). | |
| options | Argument options | |
const |
set | Sets the value of the argument. Provided values are given as extra arguments. |
| type | Argument type. |
1
Uses the call operator of the target variable with the value as parameter.
3
Calls the ++ operator of the target variable any time the parameter is found.
2
Sets the value of the target variable to true.
0
Stores the value to the target variable.
0
The argument is an option.
1
The argument is positionnal.
def (const self)
Returns the action to apply to the target variable for this argument.
def (const self)
Returns the description message for this argument.
def (const self)
Returns the help message for this argument.
def (const self)
Returns the parameter list for this argument.
def (const self)
Returns the target variable for this argument.
none
Argument name(s).
{}
Argument options
def (self, ...)
Sets the value of the argument. Provided values are given as extra arguments.
none
Argument type.
def (self, name, options)
Adds an option argument to look for while parsing.
The name parameter must be a string containing the name expected by the
script in the command line parameter for the given argument. It can also
be an array of string if several names can be used for this argument (i.e.
arguments with a short and long name).
The options parameter must be an hash containing the following values:
-
description (default:
''): Provides the description used by the help message for this argument. -
target (default:
none): Provides the target variable for this argument. - action (default: depend on target type): Provides the CommandLineParser.Action to apply to the target variable for this argument.
-
parameter (default:
[]): Provides the parameter list for this argument as an array of string.
def (self, name, options)
Adds a builtin option argument to look for while parsing.
The name parameter must be a string containing the name expected by the
script in the command line parameter for the given argument. It can also
be an array of string if several names can be used for this argument (i.e.
arguments with a short and long name).
The options parameter must be an hash containing the following values:
-
description (default:
''): Provides the description used by the help message for this argument. -
target (default:
none): Provides the target variable for this argument. - action (default: depend on target type): Provides the CommandLineParser.Action to apply to the target variable for this argument.
-
parameter (default:
[]): Provides the parameter list for this argument as an array of string.
def (self, name, options)
Adds a positionnal argument to look for while parsing.
The name parameter must be a string containing the name of the given
argument.
The options parameter must be an hash containing the following values:
-
description (default:
''): Provides the description used by the help message for this argument. -
target (default:
none): Provides the target variable for this argument. - action (default: depend on target type): Provides the CommandLineParser.Action to apply to the target variable for this argument.
[]
Internal arguments list.
none
Internal description value.
def (const self)
Returns the current script's path as an instance of System.File. This method must be called after parse in order to be initialized.
[]
Internal builtin arguments list.
def (self)
Creates a new parser.
def (const self, error_message)
Prints the error_message on the error output and exit the program with
error code ExitStatus.Failure.
{}
Internal options access.
def (const self, args)
Parses the command line arguments given by args. The args parameter
must be the va_args variable of the main module or an iterator
containing the same values.
On invalid argument, the onError method is called.
[]
Internal positionnal arguments list.
null
Internal script file.
def (self, description)
Sets the script's description to description. If provided, the --help
argument will include this description.
def (self, version)
Sets the script's version to version. If provided, the --version
argument is enabled.
def (self, printer = System.stdout)
Prints the help message on the printer described by printer.
def (self, printer = System.stdout)
Prints the version message on the printer described by printer.
none
Internal version value.
- Introduction
- Variables
-
Built-in-types
- Built-in-types#none
- Built-in-types#null
- Built-in-types#boolean
- Built-in-types#number
- Built-in-types#string
- Built-in-types#regex
- Built-in-types#array
- Built-in-types#hash
- Built-in-types#iterator
- Built-in-types#async_iterator
- Built-in-types#package
- Built-in-types#function
- Built-in-types#coroutine
- Built-in-types#library
- Built-in-types#libobject
- Arithmetic-operations
- Type-casting
- Control-structures
- Function-definition
- User-defined-types
- Work-with-modules