SIMPLE_CLI
Command-line argument parser with fluent API.
Inherits from: ARGUMENTS_32
Creation
| Feature |
Signature |
Description |
make |
|
Initialize CLI parser with default settings. |
Configuration
| Feature |
Signature |
Description |
set_app_info |
(a_name, a_description, a_version: STRING) |
Set application info for help output. |
add_flag |
(a_names, a_description: STRING) |
Add boolean flag. Names can be "v|verbose". |
add_option |
(a_names, a_description, a_arg_name: STRING) |
Add option with value placeholder. |
add_option_with_default |
(a_names, a_description, a_arg_name, a_default: STRING) |
Add option with default value. |
add_required_option |
(a_names, a_description, a_arg_name: STRING) |
Add required option (error if missing). |
disable_help_flag |
|
Disable built-in -h/--help handling. |
disable_version_flag |
|
Disable built-in -V/--version handling. |
Contract: set_app_info
set_app_info (a_name, a_description, a_version: STRING)
require
name_not_empty: not a_name.is_empty
ensure
name_set: app_name = a_name
description_set: app_description = a_description
version_set: app_version = a_version
Contract: add_flag
add_flag (a_names, a_description: STRING)
require
names_not_empty: not a_names.is_empty
Parsing
| Feature |
Signature |
Description |
parse |
|
Parse command-line arguments. |
Contract: parse
parse
ensure
parsed: has_parsed
Access: Flags
| Feature |
Signature |
Description |
has_flag |
(a_name: STRING): BOOLEAN |
Is the flag set? |
Contract: has_flag
has_flag (a_name: STRING): BOOLEAN
require
parsed: has_parsed
Access: String Options
| Feature |
Signature |
Description |
option_value |
(a_name: STRING): detachable STRING |
Get option value (or default if set). |
option_value_or_default |
(a_name, a_default: STRING): STRING |
Get value or provided default. |
has_option |
(a_name: STRING): BOOLEAN |
Is option set (or has default)? |
Contract: option_value
option_value (a_name: STRING): detachable STRING
require
parsed: has_parsed
Access: Integer Options
| Feature |
Signature |
Description |
integer_option |
(a_name: STRING): INTEGER |
Get integer value (0 if not found/not integer). |
integer_option_or_default |
(a_name: STRING; a_default: INTEGER): INTEGER |
Get integer value or default. |
Access: Boolean Options
| Feature |
Signature |
Description |
boolean_option |
(a_name: STRING): BOOLEAN |
Get boolean value. Recognizes: "true", "false", "yes", "no", "1", "0". |
Access: Arguments
| Feature |
Signature |
Description |
command |
: detachable STRING |
First positional argument. |
arguments |
: LIST [STRING] |
All positional arguments. |
arguments_after_command |
: LIST [STRING] |
Arguments after the first one. |
Status
| Feature |
Signature |
Description |
has_parsed |
: BOOLEAN |
Has parse been called? |
is_successful |
: BOOLEAN |
Did parsing succeed without errors? |
help_requested |
: BOOLEAN |
Was -h or --help specified? |
version_requested |
: BOOLEAN |
Was -V or --version specified? |
errors |
: LIST [STRING] |
List of parsing errors. |
has_errors |
: BOOLEAN |
Are there any errors? |
Help Output
| Feature |
Signature |
Description |
help_text |
: STRING |
Generate help text string. |
version_text |
: STRING |
Generate version text string. |
print_help |
|
Print help text to stdout. |
print_version |
|
Print version text to stdout. |
print_errors |
|
Print errors to stdout. |