Appearance
flap_command_line_argument_t
Command Line Argument (CLA) class.
Source: src/lib/flap_command_line_argument_t.F90
Dependencies
Contents
- command_line_argument
- free
- check
- raise_error_m_exclude
- raise_error_nargs_insufficient
- raise_error_value_missing
- raise_error_switch_unknown
- raise_error_duplicated_clas
- sanitize_defaults
- errored
- check_envvar_consistency
- check_action_consistency
- check_optional_consistency
- check_m_exclude_consistency
- check_named_consistency
- check_positional_consistency
- check_choices
- get_cla
- get_cla_from_buffer
- get_cla_list
- get_cla_list_from_buffer
- get_cla_list_varying_R16P
- 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
- cla_assign_cla
- finalize
- is_required_passed
- is_required_val_passed
- usage
- signature
- has_choices
- check_list_size
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
ACTION_STORE | character(len=*) | parameter | Store value (if invoked a value must be passed). |
ACTION_STORE_STAR | character(len=*) | parameter | Store value or revert on default if invoked alone. |
ACTION_STORE_TRUE | character(len=*) | parameter | Store .true. without the necessity of a value. |
ACTION_STORE_FALSE | character(len=*) | parameter | Store .false. without the necessity of a value. |
ACTION_PRINT_HELP | character(len=*) | parameter | Print help message. |
ACTION_PRINT_MARK | character(len=*) | parameter | Print help to Markdown file. |
ACTION_PRINT_VERS | character(len=*) | parameter | Print version. |
ARGS_SEP | character(len=*) | parameter | Arguments separator for multiple valued (list) CLA. |
ERROR_OPTIONAL_NO_DEF | integer(kind=I4P) | parameter | Optional CLA without default value. |
ERROR_REQUIRED_M_EXCLUDE | integer(kind=I4P) | parameter | Required CLA cannot exclude others. |
ERROR_POSITIONAL_M_EXCLUDE | integer(kind=I4P) | parameter | Positional CLA cannot exclude others. |
ERROR_NAMED_NO_NAME | integer(kind=I4P) | parameter | Named CLA without switch name. |
ERROR_POSITIONAL_NO_POSITION | integer(kind=I4P) | parameter | Positional CLA without position. |
ERROR_POSITIONAL_NO_STORE | integer(kind=I4P) | parameter | Positional CLA without action_store. |
ERROR_NOT_IN_CHOICES | integer(kind=I4P) | parameter | CLA value out of a specified choices. |
ERROR_MISSING_REQUIRED | integer(kind=I4P) | parameter | Missing required CLA. |
ERROR_M_EXCLUDE | integer(kind=I4P) | parameter | Two mutually exclusive CLAs have been passed. |
ERROR_CASTING_LOGICAL | integer(kind=I4P) | parameter | Error casting CLA value to logical type. |
ERROR_CHOICES_LOGICAL | integer(kind=I4P) | parameter | Error adding choices check for CLA val of logical type. |
ERROR_NO_LIST | integer(kind=I4P) | parameter | Actual CLA is not list-values. |
ERROR_NARGS_INSUFFICIENT | integer(kind=I4P) | parameter | Multi-valued CLA with insufficient arguments. |
ERROR_VALUE_MISSING | integer(kind=I4P) | parameter | Missing value of CLA. |
ERROR_UNKNOWN | integer(kind=I4P) | parameter | Unknown CLA (switch name). |
ERROR_ENVVAR_POSITIONAL | integer(kind=I4P) | parameter | Envvar not allowed for positional CLA. |
ERROR_ENVVAR_NOT_STORE | integer(kind=I4P) | parameter | Envvar not allowed action different from store; |
ERROR_ENVVAR_NARGS | integer(kind=I4P) | parameter | Envvar not allowed for list-values CLA. |
ERROR_STORE_STAR_POSITIONAL | integer(kind=I4P) | parameter | Action store* not allowed for positional CLA. |
ERROR_STORE_STAR_NARGS | integer(kind=I4P) | parameter | Action store* not allowed for list-values CLA. |
ERROR_STORE_STAR_ENVVAR | integer(kind=I4P) | parameter | Action store* not allowed for environment variable CLA. |
ERROR_ACTION_UNKNOWN | integer(kind=I4P) | parameter | Unknown CLA (switch name). |
ERROR_DUPLICATED_CLAS | integer(kind=I4P) | parameter | Duplicated CLAs passed, passed multiple instance of the same CLA. |
ERROR_MISSING_REQUIRED_VAL | integer(kind=I4P) | parameter | Missing required value of CLA. |
Derived Types
command_line_argument
Command Line Argument (CLA) class.
@note If not otherwise declared the action on CLA value is set to "store" a value.
Inheritance
Extends: object
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
progname | character(len=:) | allocatable | Program name. |
version | character(len=:) | allocatable | Program version. |
help | character(len=:) | allocatable | Help message. |
help_color | character(len=:) | allocatable | ANSI color of help messages. |
help_style | character(len=:) | allocatable | ANSI style of help messages. |
help_markdown | character(len=:) | allocatable | Longer help message, markdown formatted. |
description | character(len=:) | allocatable | Detailed description. |
license | character(len=:) | allocatable | License description. |
authors | character(len=:) | allocatable | Authors list. |
epilog | character(len=:) | allocatable | Epilogue message. |
m_exclude | character(len=:) | allocatable | Mutually exclude other CLA(s group). |
error_message | character(len=:) | allocatable | Meaningful error message to standard-error. |
error_color | character(len=:) | allocatable | ANSI color of error messages. |
error_style | character(len=:) | allocatable | ANSI style of error messages. |
examples | character(len=512) | allocatable | Examples of correct usage. |
error | integer(kind=I4P) | Error trapping flag. | |
usage_lun | integer(kind=I4P) | Output unit to print help/usage messages | |
version_lun | integer(kind=I4P) | Output unit to print version message | |
error_lun | integer(kind=I4P) | Error unit to print error messages | |
switch | character(len=:) | allocatable | Switch name. |
switch_ab | character(len=:) | allocatable | Abbreviated switch name. |
act | character(len=:) | allocatable | CLA value action. |
def | character(len=:) | allocatable | Default value. |
nargs | character(len=:) | allocatable | Number of arguments consumed by CLA. |
choices | character(len=:) | allocatable | List (comma separated) of allowable values for the argument. |
val | character(len=:) | allocatable | CLA value. |
envvar | character(len=:) | allocatable | Environment variable from which take value. |
is_required | logical | Flag for set required argument. | |
is_positional | logical | Flag for checking if CLA is a positional or a named CLA. | |
position | integer(kind=I4P) | Position of positional CLA. | |
is_passed | logical | Flag for checking if CLA has been passed to CLI. | |
is_hidden | logical | Flag for hiding CLA, thus it does not compare into help. | |
is_val_required | logical | Flag for set required value for not required (optional) CLA. |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
free_object | pass(self) | Free dynamic memory. |
print_version | pass(self) | Print version. |
print_error_message | pass(self) | Print meaningful error message. |
set_examples | pass(self) | Set examples of correct usage. |
assign_object | pass(lhs ) | Assignment overloading. |
free | Free dynamic memory. | |
check | Check data consistency. | |
is_required_passed | Check if required CLA is passed. | |
raise_error_m_exclude | Raise error mutually exclusive CLAs passed. | |
raise_error_nargs_insufficient | Raise error insufficient number of argument values passed. | |
raise_error_value_missing | Raise error missing value. | |
raise_error_switch_unknown | Raise error switch_unknown. | |
raise_error_duplicated_clas | Raise error duplicated CLAs passed. | |
get | Get CLA value(s). | |
get_varying | Get CLA value(s) from varying size list. | |
has_choices | Return true if CLA has defined choices. | |
sanitize_defaults | Sanitize default values. | |
signature | Get signature. | |
usage | Get correct usage. | |
errored | Trig error occurence and print meaningful message. | |
check_envvar_consistency | Check data consistency for envvar CLA. | |
check_action_consistency | Check CLA action consistency. | |
check_optional_consistency | Check optional CLA consistency. | |
check_m_exclude_consistency | Check mutually exclusion consistency. | |
check_named_consistency | Check named CLA consistency. | |
check_positional_consistency | Check positional CLA consistency. | |
check_choices | Check if CLA value is in allowed choices. | |
check_list_size | Check CLA multiple values list size consistency. | |
get_cla | Get CLA (single) value. | |
get_cla_from_buffer | Get CLA (single) value from a buffer. | |
get_cla_list | Get CLA multiple values. | |
get_cla_list_from_buffer | Get CLA (single) value from a buffer. | |
get_cla_list_varying_R16P | Get CLA multiple values, varying size, R16P. | |
get_cla_list_varying_R8P | Get CLA multiple values, varying size, R8P. | |
get_cla_list_varying_R4P | Get CLA multiple values, varying size, R4P. | |
get_cla_list_varying_I8P | Get CLA multiple values, varying size, I8P. | |
get_cla_list_varying_I4P | Get CLA multiple values, varying size, I4P. | |
get_cla_list_varying_I2P | Get CLA multiple values, varying size, I2P. | |
get_cla_list_varying_I1P | Get CLA multiple values, varying size, I1P. | |
get_cla_list_varying_logical | Get CLA multiple values, varying size, bool. | |
get_cla_list_varying_char | Get CLA multiple values, varying size, char. | |
cla_assign_cla | Assignment operator. | |
assignment(=) | Assignment operator overloading. |
Subroutines
free
Free dynamic memory.
Attributes: elemental
fortran
subroutine free(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. |
Call graph
check
Check data consistency.
fortran
subroutine check(self, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
raise_error_m_exclude
Raise error mutually exclusive CLAs passed.
fortran
subroutine raise_error_m_exclude(self, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
raise_error_nargs_insufficient
Raise error insufficient number of argument values passed.
fortran
subroutine raise_error_nargs_insufficient(self, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
raise_error_value_missing
Raise error missing value.
fortran
subroutine raise_error_value_missing(self, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
raise_error_switch_unknown
Raise error switch_unknown.
fortran
subroutine raise_error_switch_unknown(self, switch, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
switch | character(len=*) | in | optional | CLA switch name. |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
raise_error_duplicated_clas
Raise error duplicated CLAs passed.
fortran
subroutine raise_error_duplicated_clas(self, switch, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
switch | character(len=*) | in | optional | CLA switch name. |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
sanitize_defaults
Sanitize defaults values.
It is necessary to sanitize the default values of non-passed, optional CLA.
fortran
subroutine sanitize_defaults(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLAsG data. |
Call graph
errored
Trig error occurence and print meaningful message.
fortran
subroutine errored(self, error, pref, switch, val_str, log_value)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
error | integer(kind=I4P) | in | Error occurred. | |
pref | character(len=*) | in | optional | Prefixing string. |
switch | character(len=*) | in | optional | CLA switch name. |
val_str | character(len=*) | in | optional | Value string. |
log_value | character(len=*) | in | optional | Logical value to be casted. |
Call graph
check_envvar_consistency
Check data consistency for envvar CLA.
fortran
subroutine check_envvar_consistency(self, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
check_action_consistency
Check CLA action consistency.
fortran
subroutine check_action_consistency(self, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
check_optional_consistency
Check optional CLA consistency.
fortran
subroutine check_optional_consistency(self, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
check_m_exclude_consistency
Check mutually exclusion consistency.
fortran
subroutine check_m_exclude_consistency(self, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
check_named_consistency
Check named CLA consistency.
fortran
subroutine check_named_consistency(self, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
check_positional_consistency
Check positional CLA consistency.
fortran
subroutine check_positional_consistency(self, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
check_choices
Check if CLA value is in allowed choices.
@note This procedure can be called if and only if cla%choices has been allocated.
fortran
subroutine check_choices(self, val, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
val | class(*) | in | CLA value. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
get_cla
Get CLA (single) value.
fortran
subroutine get_cla(self, val, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
val | class(*) | inout | CLA value. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
get_cla_from_buffer
Get CLA (single) value from parsed value.
fortran
subroutine get_cla_from_buffer(self, buffer, val, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
buffer | character(len=*) | in | Buffer containing values (parsed or default CLA value). | |
val | class(*) | inout | CLA value. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
get_cla_list
Get CLA multiple values.
fortran
subroutine get_cla_list(self, pref, val)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
pref | character(len=*) | in | optional | Prefixing string. |
val | class(*) | inout | CLA values. |
Call graph
get_cla_list_from_buffer
Get CLA multiple values from a buffer.
fortran
subroutine get_cla_list_from_buffer(self, buffer, val, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
buffer | character(len=*) | in | Buffer containing values (parsed or default CLA value). | |
val | class(*) | inout | CLA value. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
get_cla_list_varying_R16P
Get CLA (multiple) value with varying size, real(R16P).
fortran
subroutine get_cla_list_varying_R16P(self, val, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
val | real(kind=R16P) | out | allocatable | CLA values. |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
get_cla_list_varying_R8P
Get CLA (multiple) value with varying size, real(R8P).
fortran
subroutine get_cla_list_varying_R8P(self, val, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
val | real(kind=R8P) | out | allocatable | CLA values. |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
get_cla_list_varying_R4P
Get CLA (multiple) value with varying size, real(R4P).
fortran
subroutine get_cla_list_varying_R4P(self, val, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
val | real(kind=R4P) | out | allocatable | CLA values. |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
get_cla_list_varying_I8P
Get CLA (multiple) value with varying size, integer(I8P).
fortran
subroutine get_cla_list_varying_I8P(self, val, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
val | integer(kind=I8P) | out | allocatable | CLA values. |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
get_cla_list_varying_I4P
Get CLA (multiple) value with varying size, integer(I4P).
fortran
subroutine get_cla_list_varying_I4P(self, val, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
val | integer(kind=I4P) | out | allocatable | CLA values. |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
get_cla_list_varying_I2P
Get CLA (multiple) value with varying size, integer(I2P).
fortran
subroutine get_cla_list_varying_I2P(self, val, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
val | integer(kind=I2P) | out | allocatable | CLA values. |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
get_cla_list_varying_I1P
Get CLA (multiple) value with varying size, integer(I1P).
fortran
subroutine get_cla_list_varying_I1P(self, val, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
val | integer(kind=I1P) | out | allocatable | CLA values. |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
get_cla_list_varying_logical
Get CLA (multiple) value with varying size, logical.
fortran
subroutine get_cla_list_varying_logical(self, val, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
val | logical | out | allocatable | CLA values. |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
get_cla_list_varying_char
Get CLA (multiple) value with varying size, character.
fortran
subroutine get_cla_list_varying_char(self, val, pref)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
val | character(len=*) | out | allocatable | CLA values. |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
cla_assign_cla
Assignment operator.
Attributes: elemental
fortran
subroutine cla_assign_cla(lhs, rhs)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lhs | class(command_line_argument) | inout | Left hand side. | |
rhs | type(command_line_argument) | in | Rigth hand side. |
Call graph
finalize
Free dynamic memory when finalizing.
Attributes: elemental
fortran
subroutine finalize(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | type(command_line_argument) | inout | CLA data. |
Functions
is_required_passed
Check if required CLA is passed.
Returns: logical
fortran
function is_required_passed(self, pref) result(is_ok)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
is_required_val_passed
Check if required value of CLA is passed.
Returns: logical
fortran
function is_required_val_passed(self, pref) result(is_ok)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph
usage
Get correct usage.
Returns: character(len=:)
fortran
function usage(self, pref, markdown)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | in | CLAs group data. | |
pref | character(len=*) | in | optional | Prefixing string. |
markdown | logical | in | optional | Format for markdown |
Call graph
signature
Get signature.
Returns: character(len=:)
fortran
function signature(self, bash_completion, plain)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | in | CLA data. | |
bash_completion | logical | in | optional | Return the signature for bash completion. |
plain | logical | in | optional | Return the signature as plain switches list. |
Call graph
has_choices
Return true if CLA has choices.
Attributes: pure
Returns: logical
fortran
function has_choices(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | in | CLA data. |
Call graph
check_list_size
Check CLA multiple values list size consistency.
Returns: logical
fortran
function check_list_size(self, Nv, val, pref) result(is_ok)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(command_line_argument) | inout | CLA data. | |
Nv | integer(kind=I4P) | in | Number of values. | |
val | character(len=*) | in | First value. | |
pref | character(len=*) | in | optional | Prefixing string. |
Call graph