Skip to content

flap_command_line_argument_t

Command Line Argument (CLA) class.

Source: src/lib/flap_command_line_argument_t.F90

Dependencies

Contents

Variables

NameTypeAttributesDescription
ACTION_STOREcharacter(len=*)parameterStore value (if invoked a value must be passed).
ACTION_STORE_STARcharacter(len=*)parameterStore value or revert on default if invoked alone.
ACTION_STORE_TRUEcharacter(len=*)parameterStore .true. without the necessity of a value.
ACTION_STORE_FALSEcharacter(len=*)parameterStore .false. without the necessity of a value.
ACTION_PRINT_HELPcharacter(len=*)parameterPrint help message.
ACTION_PRINT_MARKcharacter(len=*)parameterPrint help to Markdown file.
ACTION_PRINT_VERScharacter(len=*)parameterPrint version.
ARGS_SEPcharacter(len=*)parameterArguments separator for multiple valued (list) CLA.
ERROR_OPTIONAL_NO_DEFinteger(kind=I4P)parameterOptional CLA without default value.
ERROR_REQUIRED_M_EXCLUDEinteger(kind=I4P)parameterRequired CLA cannot exclude others.
ERROR_POSITIONAL_M_EXCLUDEinteger(kind=I4P)parameterPositional CLA cannot exclude others.
ERROR_NAMED_NO_NAMEinteger(kind=I4P)parameterNamed CLA without switch name.
ERROR_POSITIONAL_NO_POSITIONinteger(kind=I4P)parameterPositional CLA without position.
ERROR_POSITIONAL_NO_STOREinteger(kind=I4P)parameterPositional CLA without action_store.
ERROR_NOT_IN_CHOICESinteger(kind=I4P)parameterCLA value out of a specified choices.
ERROR_MISSING_REQUIREDinteger(kind=I4P)parameterMissing required CLA.
ERROR_M_EXCLUDEinteger(kind=I4P)parameterTwo mutually exclusive CLAs have been passed.
ERROR_CASTING_LOGICALinteger(kind=I4P)parameterError casting CLA value to logical type.
ERROR_CHOICES_LOGICALinteger(kind=I4P)parameterError adding choices check for CLA val of logical type.
ERROR_NO_LISTinteger(kind=I4P)parameterActual CLA is not list-values.
ERROR_NARGS_INSUFFICIENTinteger(kind=I4P)parameterMulti-valued CLA with insufficient arguments.
ERROR_VALUE_MISSINGinteger(kind=I4P)parameterMissing value of CLA.
ERROR_UNKNOWNinteger(kind=I4P)parameterUnknown CLA (switch name).
ERROR_ENVVAR_POSITIONALinteger(kind=I4P)parameterEnvvar not allowed for positional CLA.
ERROR_ENVVAR_NOT_STOREinteger(kind=I4P)parameterEnvvar not allowed action different from store;
ERROR_ENVVAR_NARGSinteger(kind=I4P)parameterEnvvar not allowed for list-values CLA.
ERROR_STORE_STAR_POSITIONALinteger(kind=I4P)parameterAction store* not allowed for positional CLA.
ERROR_STORE_STAR_NARGSinteger(kind=I4P)parameterAction store* not allowed for list-values CLA.
ERROR_STORE_STAR_ENVVARinteger(kind=I4P)parameterAction store* not allowed for environment variable CLA.
ERROR_ACTION_UNKNOWNinteger(kind=I4P)parameterUnknown CLA (switch name).
ERROR_DUPLICATED_CLASinteger(kind=I4P)parameterDuplicated CLAs passed, passed multiple instance of the same CLA.
ERROR_MISSING_REQUIRED_VALinteger(kind=I4P)parameterMissing 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

NameTypeAttributesDescription
prognamecharacter(len=:)allocatableProgram name.
versioncharacter(len=:)allocatableProgram version.
helpcharacter(len=:)allocatableHelp message.
help_colorcharacter(len=:)allocatableANSI color of help messages.
help_stylecharacter(len=:)allocatableANSI style of help messages.
help_markdowncharacter(len=:)allocatableLonger help message, markdown formatted.
descriptioncharacter(len=:)allocatableDetailed description.
licensecharacter(len=:)allocatableLicense description.
authorscharacter(len=:)allocatableAuthors list.
epilogcharacter(len=:)allocatableEpilogue message.
m_excludecharacter(len=:)allocatableMutually exclude other CLA(s group).
error_messagecharacter(len=:)allocatableMeaningful error message to standard-error.
error_colorcharacter(len=:)allocatableANSI color of error messages.
error_stylecharacter(len=:)allocatableANSI style of error messages.
examplescharacter(len=512)allocatableExamples of correct usage.
errorinteger(kind=I4P)Error trapping flag.
usage_luninteger(kind=I4P)Output unit to print help/usage messages
version_luninteger(kind=I4P)Output unit to print version message
error_luninteger(kind=I4P)Error unit to print error messages
switchcharacter(len=:)allocatableSwitch name.
switch_abcharacter(len=:)allocatableAbbreviated switch name.
actcharacter(len=:)allocatableCLA value action.
defcharacter(len=:)allocatableDefault value.
nargscharacter(len=:)allocatableNumber of arguments consumed by CLA.
choicescharacter(len=:)allocatableList (comma separated) of allowable values for the argument.
valcharacter(len=:)allocatableCLA value.
envvarcharacter(len=:)allocatableEnvironment variable from which take value.
is_requiredlogicalFlag for set required argument.
is_positionallogicalFlag for checking if CLA is a positional or a named CLA.
positioninteger(kind=I4P)Position of positional CLA.
is_passedlogicalFlag for checking if CLA has been passed to CLI.
is_hiddenlogicalFlag for hiding CLA, thus it does not compare into help.
is_val_requiredlogicalFlag for set required value for not required (optional) CLA.

Type-Bound Procedures

NameAttributesDescription
free_objectpass(self)Free dynamic memory.
print_versionpass(self)Print version.
print_error_messagepass(self)Print meaningful error message.
set_examplespass(self)Set examples of correct usage.
assign_objectpass(lhs )Assignment overloading.
freeFree dynamic memory.
checkCheck data consistency.
is_required_passedCheck if required CLA is passed.
raise_error_m_excludeRaise error mutually exclusive CLAs passed.
raise_error_nargs_insufficientRaise error insufficient number of argument values passed.
raise_error_value_missingRaise error missing value.
raise_error_switch_unknownRaise error switch_unknown.
raise_error_duplicated_clasRaise error duplicated CLAs passed.
getGet CLA value(s).
get_varyingGet CLA value(s) from varying size list.
has_choicesReturn true if CLA has defined choices.
sanitize_defaultsSanitize default values.
signatureGet signature.
usageGet correct usage.
erroredTrig error occurence and print meaningful message.
check_envvar_consistencyCheck data consistency for envvar CLA.
check_action_consistencyCheck CLA action consistency.
check_optional_consistencyCheck optional CLA consistency.
check_m_exclude_consistencyCheck mutually exclusion consistency.
check_named_consistencyCheck named CLA consistency.
check_positional_consistencyCheck positional CLA consistency.
check_choicesCheck if CLA value is in allowed choices.
check_list_sizeCheck CLA multiple values list size consistency.
get_claGet CLA (single) value.
get_cla_from_bufferGet CLA (single) value from a buffer.
get_cla_listGet CLA multiple values.
get_cla_list_from_bufferGet CLA (single) value from a buffer.
get_cla_list_varying_R16PGet CLA multiple values, varying size, R16P.
get_cla_list_varying_R8PGet CLA multiple values, varying size, R8P.
get_cla_list_varying_R4PGet CLA multiple values, varying size, R4P.
get_cla_list_varying_I8PGet CLA multiple values, varying size, I8P.
get_cla_list_varying_I4PGet CLA multiple values, varying size, I4P.
get_cla_list_varying_I2PGet CLA multiple values, varying size, I2P.
get_cla_list_varying_I1PGet CLA multiple values, varying size, I1P.
get_cla_list_varying_logicalGet CLA multiple values, varying size, bool.
get_cla_list_varying_charGet CLA multiple values, varying size, char.
cla_assign_claAssignment operator.
assignment(=)Assignment operator overloading.

Subroutines

free

Free dynamic memory.

Attributes: elemental

fortran
subroutine free(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.

Call graph

check

Check data consistency.

fortran
subroutine check(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

raise_error_m_exclude

Raise error mutually exclusive CLAs passed.

fortran
subroutine raise_error_m_exclude(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

raise_error_nargs_insufficient

Raise error insufficient number of argument values passed.

fortran
subroutine raise_error_nargs_insufficient(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

raise_error_value_missing

Raise error missing value.

fortran
subroutine raise_error_value_missing(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

raise_error_switch_unknown

Raise error switch_unknown.

fortran
subroutine raise_error_switch_unknown(self, switch, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
switchcharacter(len=*)inoptionalCLA switch name.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

raise_error_duplicated_clas

Raise error duplicated CLAs passed.

fortran
subroutine raise_error_duplicated_clas(self, switch, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
switchcharacter(len=*)inoptionalCLA switch name.
prefcharacter(len=*)inoptionalPrefixing 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLAsG data.

Call graph

errored

Trig error occurence and print meaningful message.

fortran
subroutine errored(self, error, pref, switch, val_str, log_value)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
errorinteger(kind=I4P)inError occurred.
prefcharacter(len=*)inoptionalPrefixing string.
switchcharacter(len=*)inoptionalCLA switch name.
val_strcharacter(len=*)inoptionalValue string.
log_valuecharacter(len=*)inoptionalLogical value to be casted.

Call graph

check_envvar_consistency

Check data consistency for envvar CLA.

fortran
subroutine check_envvar_consistency(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

check_action_consistency

Check CLA action consistency.

fortran
subroutine check_action_consistency(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

check_optional_consistency

Check optional CLA consistency.

fortran
subroutine check_optional_consistency(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

check_m_exclude_consistency

Check mutually exclusion consistency.

fortran
subroutine check_m_exclude_consistency(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

check_named_consistency

Check named CLA consistency.

fortran
subroutine check_named_consistency(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

check_positional_consistency

Check positional CLA consistency.

fortran
subroutine check_positional_consistency(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
prefcharacter(len=*)inoptionalPrefixing 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valclass(*)inCLA value.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

get_cla

Get CLA (single) value.

fortran
subroutine get_cla(self, val, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valclass(*)inoutCLA value.
prefcharacter(len=*)inoptionalPrefixing 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
buffercharacter(len=*)inBuffer containing values (parsed or default CLA value).
valclass(*)inoutCLA value.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

get_cla_list

Get CLA multiple values.

fortran
subroutine get_cla_list(self, pref, val)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
prefcharacter(len=*)inoptionalPrefixing string.
valclass(*)inoutCLA 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
buffercharacter(len=*)inBuffer containing values (parsed or default CLA value).
valclass(*)inoutCLA value.
prefcharacter(len=*)inoptionalPrefixing 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valreal(kind=R16P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valreal(kind=R8P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valreal(kind=R4P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valinteger(kind=I8P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valinteger(kind=I4P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valinteger(kind=I2P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valinteger(kind=I1P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
vallogicaloutallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valcharacter(len=*)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

cla_assign_cla

Assignment operator.

Attributes: elemental

fortran
subroutine cla_assign_cla(lhs, rhs)

Arguments

NameTypeIntentAttributesDescription
lhsclass(command_line_argument)inoutLeft hand side.
rhstype(command_line_argument)inRigth hand side.

Call graph

finalize

Free dynamic memory when finalizing.

Attributes: elemental

fortran
subroutine finalize(self)

Arguments

NameTypeIntentAttributesDescription
selftype(command_line_argument)inoutCLA data.

Functions

is_required_passed

Check if required CLA is passed.

Returns: logical

fortran
function is_required_passed(self, pref) result(is_ok)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
prefcharacter(len=*)inoptionalPrefixing 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

usage

Get correct usage.

Returns: character(len=:)

fortran
function usage(self, pref, markdown)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLAs group data.
prefcharacter(len=*)inoptionalPrefixing string.
markdownlogicalinoptionalFormat for markdown

Call graph

signature

Get signature.

Returns: character(len=:)

fortran
function signature(self, bash_completion, plain)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.
bash_completionlogicalinoptionalReturn the signature for bash completion.
plainlogicalinoptionalReturn 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA 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

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
Nvinteger(kind=I4P)inNumber of values.
valcharacter(len=*)inFirst value.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph