Add a argument
option | description |
---|---|
--action | Action store, store_true, store_false (default:store) |
--default | Default value |
--dest | Destination variable |
--help | Usage helper |
--metavar | Usage argument name (if not set use long/short name) |
--required | Is required if exists |
If error return 1.
args_add_argument [options...] -- [name/flags...]
# positional argument
args_add_argument -- "FOO"
# boolean optional argument
args_add_argument --action "store_true" -- "-f" "--foo"
# not boolean optional argument
args_add_argument --action="store_false" -- "-f" "--foo"
# optional argument
args_add_argument -- "-f" "--foo"
Use after args_add_argument functions.
Convert argument strings to objects and assign them as attributes on the ARGS map.
Previous calls to args_add_argument.
determine exactly what objects are created and how they are assigned.
Execute this with "$@" parameters.
If help option is called return 64 (exit code) else if error return 1 (exit code).
args_parse_arguments "$@"
Set a usage description.
Concat all arguments.
args_set_description "your description" "message"
Set a epilog description.
Concat all arguments.
args_set_epilog "your epilog" "message"
Set the widths of usage message.
Parameter | Description |
---|---|
$1 | padding |
$2 | argument |
$3 | separator |
$4 | help |
args_set_usage_width 2 20 2 56
Set the usage witdhs.
args_set_usage_width 2 20 2 56
args_set_usage_width 2 30 2 15
args_set_usage_width 1 21 1 30
Set a full usage message.
Concat all arguments.
args_set_usage "usage: my_prog [options...]" "--" "[args...]"
Set alternative mode for getopt.
args_set_alternative "true"
Show/Generate usage message.
Parameter | Description |
---|---|
$1 | Name/Path of script |
args_usage "foo.sh"
Clean all map and array for recalled.
args_clean
Show all values of arguments and options.
args_debug_values