Bash Argsparse Library.
More...
|
| __argsparse_parse_options_valuecheck (option, value) |
| Check a value given to an option.
|
|
| __argsparse_values_array_identifier (option) |
| Prints the name of the array containing all user-declared acceptable values for an option.
|
|
| argsparse_allow_no_argument (string) |
| Allow empty command lines to run.
|
|
| argsparse_check_option_type (type, value) |
| Check if a value matches a given type.
|
|
| argsparse_describe_parameters (param...) |
| Describe non-option positionnal parameters.
|
|
| argsparse_get_cumulative_array_name (option) |
| Print the name of the array used for "cumulative" and "cumulativeset" options.
|
|
| argsparse_maximum_parameters (unsigned_int) |
|
| argsparse_minimum_parameters (unsigned_int) |
|
| argsparse_option_to_identifier (option) |
| Give the identifier name associated to an option.
|
|
| argsparse_set_alias (option) |
|
| argsparse_set_cumulative_option (option, value) |
|
| argsparse_set_cumulativeset_option (option, value) |
|
| argsparse_set_option (option, value) |
|
| argsparse_set_option_with_value (option, value) |
|
| argsparse_set_option_without_value (option) |
|
| argsparse_usage () |
|
| argsparse_usage_long () |
|
| argsparse_usage_short () |
|
| set_option_help () |
|
| usage () |
|
Bash Argsparse Library.
- Author
- Damien Nadé bash-.nosp@m.args.nosp@m.parse.nosp@m.@liv.nosp@m.na.or.nosp@m.g
- Copyright
- WTFPLv2
- Version
- 1.8
◆ __argsparse_parse_options_valuecheck()
__argsparse_parse_options_valuecheck |
( |
option |
, |
|
|
value |
|
|
) |
| |
Check a value given to an option.
If an enumeration has been defined for the option, check against that. If there's no enumeration, but option has a type property, then check against the type. In the end, check against check_value_of_<option> function, if it's been defined.
- Parameters
-
option | an option name. |
value | anything. |
- Return values
-
0 | if value is correct for given option. |
◆ __argsparse_values_array_identifier()
__argsparse_values_array_identifier |
( |
option |
| ) |
|
Prints the name of the array containing all user-declared acceptable values for an option.
from "opt" or "opt-name" string, prints "option_opt_values[@]" or "option_opt_name_values[@]", unless array is not declared, in which case function will return an error.
- Parameters
-
- Return values
-
1 | if array has not been declared |
0 | else. Array name will be written to stdout. |
◆ argsparse_allow_no_argument()
argsparse_allow_no_argument |
( |
string |
| ) |
|
Allow empty command lines to run.
Change argsparse behaviour for empty command lines. Default says "no argument triggers usage".
- Parameters
-
string | if (case-insensitive) "yes", "true" or "1", the value is considered as affirmative. Anything else is a negative value. |
- Return values
-
0 | unless there's more than one parameter (or none). |
◆ argsparse_check_option_type()
argsparse_check_option_type |
( |
type |
, |
|
|
value |
|
|
) |
| |
Check if a value matches a given type.
Return True if value is of type type.
- Parameters
-
type | A case-insensitive type name. |
value | a value to check. |
- Return values
-
0 | if the value matches the given type format. |
◆ argsparse_describe_parameters()
argsparse_describe_parameters |
( |
param... |
| ) |
|
Describe non-option positionnal parameters.
This function has currently 2 purposes:
- enhance the "short" usage program description (see argsparse_usage_short())
- compute the minimum and maximum numbers of non-option positionnal parameters and will overwrite previous settings using argsparse_minimum_parameters() and argsparse_maximum_parameters().
- Parameters
-
param... | a list of label describing positionnal parameters. These labels can have special forms such as:
- "label?" a single optional non-repeatable parameter
- "label+" a non-empty list of parameters
- "label*" a potentially-empty list of parameters
- "label" a single non-optional non-repeatable parameter
|
- Return values
-
◆ argsparse_get_cumulative_array_name()
argsparse_get_cumulative_array_name |
( |
option |
| ) |
|
Print the name of the array used for "cumulative" and "cumulativeset" options.
- Parameters
-
For "option-name" usually prints "cumulated_values_option_name".
◆ argsparse_option_to_identifier()
argsparse_option_to_identifier |
( |
option |
| ) |
|
Give the identifier name associated to an option.
Transforms and prints an option name into a string which suitable to be part of a function or a variable name.
- Parameters
-
◆ argsparse_pgm
ReadOnly String argsparse_pgm |
The name of the program currently using argsparse.
Automatically set by argsparse at load time, it contains the basename (path-less but with extension, if any) of the main script. Used internally to print error messages and by usage-related functions, but can be used by the loading script.