Command Line Argument (CLA) class.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=*), | public, | parameter | :: | ACTION_STORE | = | 'STORE' |
Store value (if invoked a value must be passed). |
character(len=*), | public, | parameter | :: | ACTION_STORE_STAR | = | 'STORE*' |
Store value or revert on default if invoked alone. |
character(len=*), | public, | parameter | :: | ACTION_STORE_TRUE | = | 'STORE_TRUE' |
Store .true. without the necessity of a value. |
character(len=*), | public, | parameter | :: | ACTION_STORE_FALSE | = | 'STORE_FALSE' |
Store .false. without the necessity of a value. |
character(len=*), | public, | parameter | :: | ACTION_PRINT_HELP | = | 'PRINT_HELP' |
Print help message. |
character(len=*), | public, | parameter | :: | ACTION_PRINT_MARK | = | 'PRINT_MARKDOWN' |
Print help to Markdown file. |
character(len=*), | public, | parameter | :: | ACTION_PRINT_VERS | = | 'PRINT_VERSION' |
Print version. |
character(len=*), | public, | parameter | :: | ARGS_SEP | = | '||!||' |
Arguments separator for multiple valued (list) CLA. |
integer(kind=I4P), | private, | parameter | :: | ERROR_OPTIONAL_NO_DEF | = | 1 |
Optional CLA without default value. |
integer(kind=I4P), | private, | parameter | :: | ERROR_REQUIRED_M_EXCLUDE | = | 2 |
Required CLA cannot exclude others. |
integer(kind=I4P), | private, | parameter | :: | ERROR_POSITIONAL_M_EXCLUDE | = | 3 |
Positional CLA cannot exclude others. |
integer(kind=I4P), | private, | parameter | :: | ERROR_NAMED_NO_NAME | = | 4 |
Named CLA without switch name. |
integer(kind=I4P), | private, | parameter | :: | ERROR_POSITIONAL_NO_POSITION | = | 5 |
Positional CLA without position. |
integer(kind=I4P), | private, | parameter | :: | ERROR_POSITIONAL_NO_STORE | = | 6 |
Positional CLA without action_store. |
integer(kind=I4P), | private, | parameter | :: | ERROR_NOT_IN_CHOICES | = | 7 |
CLA value out of a specified choices. |
integer(kind=I4P), | private, | parameter | :: | ERROR_MISSING_REQUIRED | = | 8 |
Missing required CLA. |
integer(kind=I4P), | private, | parameter | :: | ERROR_M_EXCLUDE | = | 9 |
Two mutually exclusive CLAs have been passed. |
integer(kind=I4P), | private, | parameter | :: | ERROR_CASTING_LOGICAL | = | 10 |
Error casting CLA value to logical type. |
integer(kind=I4P), | private, | parameter | :: | ERROR_CHOICES_LOGICAL | = | 11 |
Error adding choices check for CLA val of logical type. |
integer(kind=I4P), | private, | parameter | :: | ERROR_NO_LIST | = | 12 |
Actual CLA is not list-values. |
integer(kind=I4P), | private, | parameter | :: | ERROR_NARGS_INSUFFICIENT | = | 13 |
Multi-valued CLA with insufficient arguments. |
integer(kind=I4P), | private, | parameter | :: | ERROR_VALUE_MISSING | = | 14 |
Missing value of CLA. |
integer(kind=I4P), | public, | parameter | :: | ERROR_UNKNOWN | = | 15 |
Unknown CLA (switch name). |
integer(kind=I4P), | private, | parameter | :: | ERROR_ENVVAR_POSITIONAL | = | 16 |
Envvar not allowed for positional CLA. |
integer(kind=I4P), | private, | parameter | :: | ERROR_ENVVAR_NOT_STORE | = | 17 |
Envvar not allowed action different from store; |
integer(kind=I4P), | private, | parameter | :: | ERROR_ENVVAR_NARGS | = | 18 |
Envvar not allowed for list-values CLA. |
integer(kind=I4P), | private, | parameter | :: | ERROR_STORE_STAR_POSITIONAL | = | 19 |
Action store* not allowed for positional CLA. |
integer(kind=I4P), | private, | parameter | :: | ERROR_STORE_STAR_NARGS | = | 20 |
Action store* not allowed for list-values CLA. |
integer(kind=I4P), | private, | parameter | :: | ERROR_STORE_STAR_ENVVAR | = | 21 |
Action store* not allowed for environment variable CLA. |
integer(kind=I4P), | private, | parameter | :: | ERROR_ACTION_UNKNOWN | = | 22 |
Unknown CLA (switch name). |
integer(kind=I4P), | private, | parameter | :: | ERROR_DUPLICATED_CLAS | = | 23 |
Duplicated CLAs passed, passed multiple instance of the same CLA. |
integer(kind=I4P), | private, | parameter | :: | ERROR_MISSING_REQUIRED_VAL | = | 24 |
Missing required value of CLA. |
Command Line Argument (CLA) class.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=:), | public, | allocatable | :: | progname |
Program name. |
||
character(len=:), | public, | allocatable | :: | version |
Program version. |
||
character(len=:), | public, | allocatable | :: | help |
Help message. |
||
character(len=:), | public, | allocatable | :: | help_color |
ANSI color of help messages. |
||
character(len=:), | public, | allocatable | :: | help_style |
ANSI style of help messages. |
||
character(len=:), | public, | allocatable | :: | help_markdown |
Longer help message, markdown formatted. |
||
character(len=:), | public, | allocatable | :: | description |
Detailed description. |
||
character(len=:), | public, | allocatable | :: | license |
License description. |
||
character(len=:), | public, | allocatable | :: | authors |
Authors list. |
||
character(len=:), | public, | allocatable | :: | epilog |
Epilogue message. |
||
character(len=:), | public, | allocatable | :: | m_exclude |
Mutually exclude other CLA(s group). |
||
character(len=:), | public, | allocatable | :: | error_message |
Meaningful error message to standard-error. |
||
character(len=:), | public, | allocatable | :: | error_color |
ANSI color of error messages. |
||
character(len=:), | public, | allocatable | :: | error_style |
ANSI style of error messages. |
||
character(len=512), | public, | allocatable | :: | examples(:) |
Examples of correct usage. |
||
integer(kind=I4P), | public | :: | error | = | 0_I4P |
Error trapping flag. |
|
integer(kind=I4P), | public | :: | usage_lun | = | stderr |
Output unit to print help/usage messages |
|
integer(kind=I4P), | public | :: | version_lun | = | stdout |
Output unit to print version message |
|
integer(kind=I4P), | public | :: | error_lun | = | stderr |
Error unit to print error messages |
|
character(len=:), | public, | allocatable | :: | switch |
Switch name. |
||
character(len=:), | public, | allocatable | :: | switch_ab |
Abbreviated switch name. |
||
character(len=:), | public, | allocatable | :: | act |
CLA value action. |
||
character(len=:), | public, | allocatable | :: | def |
Default value. |
||
character(len=:), | public, | allocatable | :: | nargs |
Number of arguments consumed by CLA. |
||
character(len=:), | public, | allocatable | :: | choices |
List (comma separated) of allowable values for the argument. |
||
character(len=:), | public, | allocatable | :: | val |
CLA value. |
||
character(len=:), | public, | allocatable | :: | envvar |
Environment variable from which take value. |
||
logical, | public | :: | is_required | = | .false. |
Flag for set required argument. |
|
logical, | public | :: | is_positional | = | .false. |
Flag for checking if CLA is a positional or a named CLA. |
|
integer(kind=I4P), | public | :: | position | = | 0_I4P |
Position of positional CLA. |
|
logical, | public | :: | is_passed | = | .false. |
Flag for checking if CLA has been passed to CLI. |
|
logical, | public | :: | is_hidden | = | .false. |
Flag for hiding CLA, thus it does not compare into help. |
|
logical, | public | :: | is_val_required | = | .true. |
Flag for set required value for not required (optional) CLA. |
final :: finalize | Free dynamic memory when finalizing. |
procedure, public, pass(self) :: free_object | ../../../../ Free dynamic memory. |
procedure, public, pass(self) :: print_version | ../../../../ Print version. |
procedure, public, pass(self) :: print_error_message | ../../../../ Print meaningful error message. |
procedure, public, pass(self) :: set_examples | ../../../../ Set examples of correct usage. |
procedure, public, pass(lhs ) :: assign_object | ../../../../ Assignment overloading. |
procedure, public :: free | ../../../../ Free dynamic memory. |
procedure, public :: check | ../../../../ Check data consistency. |
procedure, public :: is_required_passed | ../../../../ Check if required CLA is passed. |
procedure, public :: raise_error_m_exclude | ../../../../ Raise error mutually exclusive CLAs passed. |
procedure, public :: raise_error_nargs_insufficient | ../../../../ Raise error insufficient number of argument values passed. |
procedure, public :: raise_error_value_missing | ../../../../ Raise error missing value. |
procedure, public :: raise_error_switch_unknown | ../../../../ Raise error switch_unknown. |
procedure, public :: raise_error_duplicated_clas | ../../../../ Raise error duplicated CLAs passed. |
generic, public :: get => get_cla, get_cla_list | ../../../../ Get CLA value(s). |
generic, public :: get_varying => get_cla_list_varying_R8P, get_cla_list_varying_R4P, get_cla_list_varying_I8P, get_cla_list_varying_I4P, get_cla_list_varying_I2P, get_cla_list_varying_I1P, get_cla_list_varying_logical, get_cla_list_varying_char | ../../../../ Get CLA value(s) from varying size list. |
procedure, public :: has_choices | ../../../../ Return true if CLA has defined choices. |
procedure, public :: sanitize_defaults | ../../../../ Sanitize default values. |
procedure, public :: signature | ../../../../ Get signature. |
procedure, public :: usage | ../../../../ Get correct usage. |
procedure, private :: errored | ../../../../ Trig error occurence and print meaningful message. |
procedure, private :: check_envvar_consistency | ../../../../ Check data consistency for envvar CLA. |
procedure, private :: check_action_consistency | ../../../../ Check CLA action consistency. |
procedure, private :: check_optional_consistency | ../../../../ Check optional CLA consistency. |
procedure, private :: check_m_exclude_consistency | ../../../../ Check mutually exclusion consistency. |
procedure, private :: check_named_consistency | ../../../../ Check named CLA consistency. |
procedure, private :: check_positional_consistency | ../../../../ Check positional CLA consistency. |
procedure, private :: check_choices | ../../../../ Check if CLA value is in allowed choices. |
procedure, private :: check_list_size | ../../../../ Check CLA multiple values list size consistency. |
procedure, private :: get_cla | ../../../../ Get CLA (single) value. |
procedure, private :: get_cla_from_buffer | ../../../../ Get CLA (single) value from a buffer. |
procedure, private :: get_cla_list | ../../../../ Get CLA multiple values. |
procedure, private :: get_cla_list_from_buffer | ../../../../ Get CLA (single) value from a buffer. |
procedure, private :: get_cla_list_varying_R16P | ../../../../ Get CLA multiple values, varying size, R16P. |
procedure, private :: get_cla_list_varying_R8P | ../../../../ Get CLA multiple values, varying size, R8P. |
procedure, private :: get_cla_list_varying_R4P | ../../../../ Get CLA multiple values, varying size, R4P. |
procedure, private :: get_cla_list_varying_I8P | ../../../../ Get CLA multiple values, varying size, I8P. |
procedure, private :: get_cla_list_varying_I4P | ../../../../ Get CLA multiple values, varying size, I4P. |
procedure, private :: get_cla_list_varying_I2P | ../../../../ Get CLA multiple values, varying size, I2P. |
procedure, private :: get_cla_list_varying_I1P | ../../../../ Get CLA multiple values, varying size, I1P. |
procedure, private :: get_cla_list_varying_logical | ../../../../ Get CLA multiple values, varying size, bool. |
procedure, private :: get_cla_list_varying_char | ../../../../ Get CLA multiple values, varying size, char. |
procedure, private :: cla_assign_cla | ../../../../ Assignment operator. |
generic, private :: assignment(=) => cla_assign_cla | ../../../../ Assignment operator overloading. |
Check if required CLA is passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Check result.
Check if required value of CLA is passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Check result.
Get correct usage.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(in) | :: | self |
CLAs group data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
|
logical, | intent(in), | optional | :: | markdown |
Format for markdown |
Usage string.
Get signature.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(in) | :: | self |
CLA data. |
||
logical, | intent(in), | optional | :: | bash_completion |
Return the signature for bash completion. |
|
logical, | intent(in), | optional | :: | plain |
Return the signature as plain switches list. |
Signature.
Return true if CLA has choices.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(in) | :: | self |
CLA data. |
Check result.
Check CLA multiple values list size consistency.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
integer(kind=I4P), | intent(in) | :: | Nv |
Number of values. |
||
character(len=*), | intent(in) | :: | val |
First value. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Check result.
Free dynamic memory.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
Check data consistency.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Raise error mutually exclusive CLAs passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Raise error insufficient number of argument values passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Raise error missing value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Raise error switch_unknown.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | switch |
CLA switch name. |
|
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Raise error duplicated CLAs passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | switch |
CLA switch name. |
|
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Sanitize defaults values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLAsG data. |
Trig error occurence and print meaningful message.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
integer(kind=I4P), | intent(in) | :: | error |
Error occurred. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
|
character(len=*), | intent(in), | optional | :: | switch |
CLA switch name. |
|
character(len=*), | intent(in), | optional | :: | val_str |
Value string. |
|
character(len=*), | intent(in), | optional | :: | log_value |
Logical value to be casted. |
Check data consistency for envvar CLA.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Check CLA action consistency.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Check optional CLA consistency.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Check mutually exclusion consistency.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Check named CLA consistency.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Check positional CLA consistency.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Check if CLA value is in allowed choices.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
class(*), | intent(in) | :: | val |
CLA value. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Get CLA (single) value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
class(*), | intent(inout) | :: | val |
CLA value. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Get CLA (single) value from parsed value.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in) | :: | buffer |
Buffer containing values (parsed or default CLA value). |
||
class(*), | intent(inout) | :: | val |
CLA value. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Get CLA multiple values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
|
class(*), | intent(inout) | :: | val(1:) |
CLA values. |
Get CLA multiple values from a buffer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in) | :: | buffer |
Buffer containing values (parsed or default CLA value). |
||
class(*), | intent(inout) | :: | val(1:) |
CLA value. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Get CLA (multiple) value with varying size, real(R16P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
real(kind=R16P), | intent(out), | allocatable | :: | val(:) |
CLA values. |
|
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Get CLA (multiple) value with varying size, real(R8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
real(kind=R8P), | intent(out), | allocatable | :: | val(:) |
CLA values. |
|
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Get CLA (multiple) value with varying size, real(R4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
real(kind=R4P), | intent(out), | allocatable | :: | val(:) |
CLA values. |
|
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Get CLA (multiple) value with varying size, integer(I8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
integer(kind=I8P), | intent(out), | allocatable | :: | val(:) |
CLA values. |
|
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Get CLA (multiple) value with varying size, integer(I4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
integer(kind=I4P), | intent(out), | allocatable | :: | val(:) |
CLA values. |
|
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Get CLA (multiple) value with varying size, integer(I2P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
integer(kind=I2P), | intent(out), | allocatable | :: | val(:) |
CLA values. |
|
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Get CLA (multiple) value with varying size, integer(I1P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
integer(kind=I1P), | intent(out), | allocatable | :: | val(:) |
CLA values. |
|
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Get CLA (multiple) value with varying size, logical.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
logical, | intent(out), | allocatable | :: | val(:) |
CLA values. |
|
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Get CLA (multiple) value with varying size, character.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(out), | allocatable | :: | val(:) |
CLA values. |
|
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Assignment operator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_argument), | intent(inout) | :: | lhs |
Left hand side. |
||
type(command_line_argument), | intent(in) | :: | rhs |
Rigth hand side. |
Free dynamic memory when finalizing.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(command_line_argument), | intent(inout) | :: | self |
CLA data. |