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
SOURCE_COMMANDLINEinteger(kind=I4P)parameterValue passed on the command line.
SOURCE_ENVIRONMENTinteger(kind=I4P)parameterValue read from the environment variable.
SOURCE_CONFIGinteger(kind=I4P)parameterValue read from a configuration file.
SOURCE_DEFAULTinteger(kind=I4P)parameterDefault value.
SOURCE_NONEinteger(kind=I4P)parameterNo value.
ACTION_STOREcharacter(len=*)parameterStore value (if invoked a value must be passed).
ACTION_CONFIGcharacter(len=*)parameterName the configuration file (stored as a store CLA).
ACTION_ALTERNATEcharacter(len=*)parameterAlternate action: bypass the value validation (F16).
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_MANcharacter(len=*)parameterSave the man page (F29).
ACTION_SHOW_COMPLETIONcharacter(len=*)parameterPrint the completion script (F24).
ACTION_INSTALL_COMPLETIONcharacter(len=*)parameterInstall the completion script (F24).
ACTION_PRINT_VERScharacter(len=*)parameterPrint version.
ACTION_COUNTcharacter(len=*)parameterCount the occurrences (repeatable, no value).
ACTION_APPENDcharacter(len=*)parameterCollect one value per occurrence (repeatable).
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.
ERROR_INLINE_VALUE_NOT_ALLOWEDinteger(kind=I4P)parameterInline value (NAME=VALUE) for a CLA that takes no value.
ERROR_INLINE_VALUE_NARGSinteger(kind=I4P)parameterInline value (NAME=VALUE) for a list CLA.
ERROR_COUNT_INCONSISTENTinteger(kind=I4P)parameterCount CLA with positional, nargs, envvar or choices.
ERROR_APPEND_INCONSISTENTinteger(kind=I4P)parameterAppend CLA with positional, nargs or envvar.
ERROR_APPEND_SCALAR_GETinteger(kind=I4P)parameterScalar get of an append CLA (a list).
ERROR_POSITIONAL_NARGSinteger(kind=I4P)parameterPositional CLA with nargs (positionals are scalar).
ERROR_UNSUPPORTED_TYPEinteger(kind=I4P)parameterValue requested into a variable of an unsupported type.
ERROR_LIST_SIZEinteger(kind=I4P)parameterList requested into a fixed-size array of another size.
ERROR_DEF_NARGSinteger(kind=I4P)parameterList default whose count differs from an integer nargs.
ERROR_ENVVAR_CSVinteger(kind=I4P)parameterList value of an environment variable: unterminated quote.
ERROR_PATH_NOT_FOUNDinteger(kind=I4P)parameterPath value that does not exist (must_exist, readable).
ERROR_PATH_NOT_READABLEinteger(kind=I4P)parameterPath value that cannot be opened for reading (readable).
ERROR_PATH_NOT_WRITABLEinteger(kind=I4P)parameterExisting path value that cannot be opened for writing.
ERROR_PATH_INCONSISTENTinteger(kind=I4P)parameterPath checks on an option taking no value.
ERROR_CASTING_NUMBERinteger(kind=I4P)parameterA value that is not a number, got into one (B40 of #126).
ERROR_DEPRECATED_REQUIREDinteger(kind=I4P)parameterA required option cannot be deprecated.
ERROR_ALTERNATE_INCONSISTENTinteger(kind=I4P)parameterAn alternate action with an attribute of a value.
ERROR_SWITCH_NEG_INCONSISTENTinteger(kind=I4P)parameterA negation (switch_neg) of a CLA that is not a named flag.
ERROR_MAP_FORMATinteger(kind=I4P)parameterA map item that is not KEY=VALUE (empty KEY included).
ERROR_MAP_DUPLICATE_KEYinteger(kind=I4P)parameterA map key given twice.
ERROR_MAP_UNKNOWN_KEYinteger(kind=I4P)parameterA map key outside map_keys.
ERROR_MAP_KEY_MISSINGinteger(kind=I4P)parameterA map key not given, looked up without found.
ERROR_MAP_INCONSISTENTinteger(kind=I4P)parameterA map on a CLA that is not a named list, or not a map.
ERROR_RANGE_DEFINITIONinteger(kind=I4P)parameterInvalid range (bounds, clamp to an open real bound).
ERROR_OUT_OF_RANGEinteger(kind=I4P)parameterValue out of its range.
ERROR_RANGE_TYPEinteger(kind=I4P)parameterRange with a character or logical get.

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.
examplestype(flap_string)allocatableExamples of correct usage (examples(i)%s).
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
case_insensitivelogicalMatch switches and command names in any case (F14).
switchcharacter(len=:)allocatableSwitch name.
switch_abcharacter(len=:)allocatableAbbreviated switch name.
switch_negcharacter(len=:)allocatableNegation of a flag, --no-x (F11); allocated if any.
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.
sourceinteger(kind=I4P)Source of the value (SOURCE_*).
is_configlogicalThe CLA names the configuration file (act='config').
must_existlogicalThe value is a path that must exist.
readablelogicalThe value is a path that must be readable (and exist).
writablelogicalThe value is a path writable if it exists.
allow_dashlogical'-' passes the path checks (standard input/output).
deprecatedcharacter(len=:)allocatableDeprecation message; allocated means deprecated (F13).
range_mincharacter(len=:)allocatableMinimum of the value (F05), as given.
range_maxcharacter(len=:)allocatableMaximum of the value (F05), as given.
min_openlogicalThe minimum is excluded.
max_openlogicalThe maximum is excluded.
clamplogicalAn out-of-range value becomes the bound.
case_sensitivelogicalCharacter choices match only in their case (F14).
is_maplogicalThe values are KEY=VALUE pairs (F18).
is_auto_envvarlogicalThe envvar is generated by auto_envvar_prefix (F07).
metavarcharacter(len=:)allocatablePlaceholder of the value in the help (F12).
map_keyscharacter(len=:)allocatableAllowed keys of a map, comma separated (F18).
is_negatedlogicalThe last spelling of a flag pair passed is the negation.
pair_passedlogicalBoth spellings of a flag pair passed (D5: once each).

Type-Bound Procedures ​

NameAttributesDescription
error_prefixpass(self)Prefix of error messages.
free_objectpass(self)Free dynamic memory.
print_versionpass(self)Print version.
print_error_messagepass(self)Print meaningful error message.
inherit_errorpass(self)Take the error of another object, with its message.
clear_errorpass(self)Forget the error and its 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.
has_valueCheck if the value is given by the user (explicit source).
set_source_valueSet a value read from the environment or a configuration file.
config_keyKey of the CLA in a configuration file.
takes_config_valueCheck if the CLA takes a value from a configuration file.
value_textResolved value as text (provenance report).
has_path_checksCheck if the value is a path to check.
deprecation_noteMarker of a deprecated CLA in the help.
has_rangeCheck if the value has a range.
range_textRange as text, e.g. (0, 1].
check_pathsCheck the path value(s): existence and permissions.
match_tokenCheck if a command line token names this CLA.
match_negationCheck if a command line token is the negation of this flag.
same_nameCompare a switch name with a token (case rule of F14).
is_pair_overrideCheck if a flag passed may be passed again by its other spelling.
flag_valueValue of a flag passed on the command line.
namesVisible switch names, for suggestions.
placeholderPlaceholder of the value in the help (metavar).
check_mapCheck the KEY=VALUE pairs of a map.
get_mapGet the keys and values of a map.
get_map_valueGet the value of a key of a map.
match_inline_tokenCheck a token also as NAME=VALUE.
set_inline_valueSet the value given inline (NAME=VALUE).
is_repeatableCheck if the CLA may be passed more than once.
count_occurrencesCount occurrences of a count CLA.
append_valueCollect a value of an append CLA.
is_listCheck if the CLA holds a list (nargs or append).
is_builtinCheck if the CLA is a builtin (help, version, man, ...).
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.
signature_usageGet the signature for the usage text.
completion_wordsGet the bash completion words (switches).
completion_offerGet the bash lines offering the words not yet typed.
completion_valuesGet the bash completion of the value.
completion_fishGet the fish completion lines.
completion_powershellGet the PowerShell completion entries.
usageGet correct usage.
erroredTrig error occurence and print meaningful message.
check_count_consistencyCheck data consistency for count CLA.
check_append_consistencyCheck data consistency for append CLA.
check_envvar_consistencyCheck data consistency for envvar CLA.
check_action_consistencyCheck CLA action consistency.
check_optional_consistencyCheck optional CLA consistency.
check_def_nargs_consistencyCheck the count of a list default against nargs.
check_m_exclude_consistencyCheck mutually exclusion consistency.
check_path_consistencyCheck that the path checks are on an option taking a value.
check_alternate_consistencyCheck that an alternate action has no attribute of a value.
check_switch_neg_consistencyCheck that a negation belongs to a named scalar flag.
check_map_consistencyCheck that a map is a named list, its default included.
check_map_listCheck the KEY=VALUE pairs of a stored list.
check_range_consistencyCheck the range definition.
check_rangeCheck (or clamp) a value against the range.
check_named_consistencyCheck named CLA consistency.
check_positional_consistencyCheck positional CLA consistency.
check_choicesCheck if CLA value is in allowed choices.
check_choices_textCheck the choices of a whole character value, then store it.
cast_numberConvert a value to a number, quietly (B40 of #126).
check_list_sizeCheck CLA multiple values list size consistency.
stored_listStored list of values (parsed or default).
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.

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

set_source_value ​

Set a value read from the environment variable (F07 of #125) or from a configuration file (F08), with its source.

A flag (store_true/store_false) takes it as its value: 1/0, true/false, t/f, yes/no, y/n, on/off, in any case (click's set); anything else is kept, so that get reports ERROR_CASTING_LOGICAL. A list (nargs) reads an environment variable as one CSV record (F22: an unterminated quote is ERROR_ENVVAR_CSV), a configuration value as blank separated values (as def).

fortran
subroutine set_source_value(self, value, source)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valuecharacter(len=*)inValue.
sourceinteger(kind=I4P)inSOURCE_ENVIRONMENT or SOURCE_CONFIG.

Call graph

check_paths ​

Check the path value(s), whatever their source (F09 of #125): every item of a list; an empty value, and '-' with allow_dash, are not checked. Standard Fortran only: inquire for existence, an open for reading (readable) or for appending, writing nothing (writable, only if the file exists); the message carries the reason of the processor. Directories are not told apart: a directory exists and opens for reading.

fortran
subroutine check_paths(self, pref)

Arguments

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

Call graph

match_inline_token ​

Check if a command line token names this CLA by rule 1 (match_token) or rule 2 of decision D1: NAME=VALUE, split at the first '=', with NAME matching by rule 1 (inline values, F01).

Attributes: pure

fortran
subroutine match_inline_token(self, token, match, inline_val, has_inline)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.
tokencharacter(len=*)inCommand line token.
matchlogicaloutCheck result.
inline_valcharacter(len=:)outallocatableVALUE of NAME=VALUE ('' otherwise).
has_inlinelogicaloutThe token is NAME=VALUE.

Call graph

append_value ​

Collect one value of an append CLA; the first occurrence replaces the default (D9 of #125). An empty value is an empty item (D17, reversed in step 2.11).

fortran
subroutine append_value(self, value, first, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valuecharacter(len=*)inValue.
firstlogicalinFirst occurrence on the command line.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

count_occurrences ​

Add n occurrences to a count CLA; the first occurrence starts from 0 (the default applies only when not passed).

fortran
subroutine count_occurrences(self, n, first)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
ninteger(kind=I4P)inOccurrences to add.
firstlogicalinFirst occurrence on the command line.

Call graph

set_inline_value ​

Set the value given inline (NAME=VALUE, F01): only a scalar store takes one; the next argument is not consumed.

An empty value (NAME=) is the empty string, as a separate empty value (D17 of #125, reversed in step 2.11).

fortran
subroutine set_inline_value(self, value, pref, first)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valuecharacter(len=*)inInline value.
prefcharacter(len=*)inoptionalPrefixing string.
firstlogicalinoptionalFirst occurrence on the command line (append, default .true.).

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, hint, quiet)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
switchcharacter(len=*)inoptionalCLA switch name.
prefcharacter(len=*)inoptionalPrefixing string.
hintcharacter(len=*)inoptional"Did you mean" hint, appended to the message (F10).
quietlogicalinoptionalBuild the message without printing it (an ignored argument).

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, hint, type_name, quiet)

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.
hintcharacter(len=*)inoptionalHint appended to the message (unknown switch, F10).
type_namecharacter(len=*)inoptionalType a value cannot be converted to ('an integer', 'a real').
quietlogicalinoptionalBuild the message without printing it (default .false.).

Call graph

check_count_consistency ​

Check count CLA consistency: a named flag without nargs, envvar or choices (F02 of #125).

fortran
subroutine check_count_consistency(self, pref)

Arguments

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

Call graph

check_append_consistency ​

Check append CLA consistency: a named option collecting one value per occurrence, without nargs or envvar (F02).

fortran
subroutine check_append_consistency(self, pref)

Arguments

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

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_def_nargs_consistency ​

Check that a list default has as many values as an integer nargs (B28 of #125); '+' and '*' take any count.

fortran
subroutine check_def_nargs_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_range_consistency ​

Check the range (F05 of #125): an option taking a value (store, store*, append, count), numeric bounds, min <= max (min < max when a bound is open).

fortran
subroutine check_range_consistency(self, pref)

Arguments

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

Call graph

check_range ​

Check a value against the range (F05 of #125), in its kind: out of range is ERROR_OUT_OF_RANGE, or, with clamp, the value becomes the bound (an open integer bound: bound +/- 1; a real cannot clamp to an open bound, ERROR_RANGE_DEFINITION). A character or logical get is ERROR_RANGE_TYPE.

fortran
subroutine check_range(self, val, text, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valclass(*)inoutValue.
textcharacter(len=*)inValue as given, for the messages.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

check_alternate_consistency ​

Check that an alternate action (F16 of #125) is a plain flag: no nargs, envvar, positional, choices, required, exclude.

fortran
subroutine check_alternate_consistency(self, pref)

Arguments

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

Call graph

check_switch_neg_consistency ​

Check that a negation (switch_neg, F11 of #125) belongs to a named scalar flag and differs from its own names.

fortran
subroutine check_switch_neg_consistency(self, pref)

Arguments

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

Call graph

check_map_consistency ​

Check a map (F18 of #125): a named store list (nargs) or append, without choices, not the configuration file; map_keys only on a map. The default pairs are checked as passed ones.

fortran
subroutine check_map_consistency(self, pref)

Arguments

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

Call graph

check_map ​

Check the KEY=VALUE pairs of a map, whatever their source (F18 of #125): called by parse after the values are settled.

fortran
subroutine check_map(self, pref)

Arguments

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

Call graph

check_map_list ​

Check the items of a stored list as KEY=VALUE pairs: format (a non-empty KEY before the first '='), repeated keys, and the map_keys whitelist (with a "Did you mean" hint).

fortran
subroutine check_map_list(self, list, pref)

Arguments

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

Call graph

get_map ​

Get the keys and values of a map (F18 of #125), in the order given; ERROR_MAP_INCONSISTENT if the CLA is not a map.

fortran
subroutine get_map(self, keys, values, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
keyscharacter(len=*)outallocatableKeys.
valuescharacter(len=*)outallocatableValues.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

get_map_value ​

Get the value of a key of a map, converted to the type of val (F18 of #125). A missing key leaves val untouched: found=.false., or ERROR_MAP_KEY_MISSING without found. A conversion error keeps its code and names the key.

fortran
subroutine get_map_value(self, key, val, found, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
keycharacter(len=*)inKey.
valclass(*)inoutValue.
foundlogicaloutoptionalThe key is in the map.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

check_path_consistency ​

Check that the path checks (must_exist, readable, writable, allow_dash) are on an option taking a value: store, store* or append (F09 of #125).

fortran
subroutine check_path_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, text)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valclass(*)inoutCLA value; a character one becomes the declared spelling.
prefcharacter(len=*)inoptionalPrefixing string.
textcharacter(len=*)inoptionalThe value as given, for the message (not the number re-written).

Call graph

check_choices_text ​

Check the choices of a character value on the whole value, then store it into the caller's variable (B38 of #126).

A variable shorter than the value holds it truncated (fex in a character(2) is fe, a choice): the check must come first. With case_sensitive=.false. the variable receives the declared spelling of the choice.

fortran
subroutine check_choices_text(self, text, val, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
textcharacter(len=*)inWhole value.
valcharacter(len=*)inoutCaller's variable.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

cast_number ​

Convert a value to the number type of val, quietly: a failure is ERROR_CASTING_NUMBER, reported by FLAP (B40 of #126).

PENF's cton writes its own message on standard error (not on the error unit of the CLI) and returns the I/O status as the error: values are never converted with it.

fortran
subroutine cast_number(self, text, val, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
textcharacter(len=*)inValue.
valclass(*)inoutNumber.
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_character ​

Get CLA multiple values into a character array, checking the choices of each value.

fortran
subroutine get_cla_list_character(self, val, vals, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inoutCLA data.
valcharacter(len=*)inoutCLA values.
valscharacter(len=*)inValues to store.
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

finalize ​

Free dynamic memory when finalizing.

Attributes: elemental

fortran
subroutine finalize(self)

Arguments

NameTypeIntentAttributesDescription
selftype(command_line_argument)inoutCLA data.

read_real ​

Read a real from a string, quietly (cton prints an error message).

fortran
subroutine read_real(string, x, ok)

Arguments

NameTypeIntentAttributesDescription
stringcharacter(len=*)inString.
xreal(kind=R8P)outValue.
oklogicaloutThe string is a number.

Call graph

read_integer ​

Read an integer from a string, quietly.

fortran
subroutine read_integer(string, i, ok)

Arguments

NameTypeIntentAttributesDescription
stringcharacter(len=*)inString.
iinteger(kind=I8P)outValue.
oklogicaloutThe string is an integer.

Functions ​

is_required_passed ​

Check if required CLA is passed: a required CLA, or one without default, needs a value from an explicit source (D2).

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

has_value ​

Check if the value is given by the user, from an explicit source (command line, environment, config): not the default.

The getters read val when this is true and def otherwise; is_passed keeps its meaning, "seen on the command line".

Attributes: elemental

Returns: logical

fortran
function has_value(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

config_key ​

Return the key of the CLA in a configuration file: its switch without the leading dashes ('' for a positional).

Attributes: pure

Returns: character(len=:)

fortran
function config_key(self) result(key)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

value_text ​

Return the resolved value as text, for the provenance report: a list blank separated, a flag passed on the command line as .true./.false., otherwise the value from its source (or the default).

Returns: character(len=:)

fortran
function value_text(self) result(text)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

deprecation_note ​

Return the marker of a deprecated CLA in the help: ' (DEPRECATED: message)', ' (DEPRECATED)', or '' (F13 of #125).

Attributes: pure

Returns: character(len=:)

fortran
function deprecation_note(self) result(note)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

has_range ​

Check if the value has a range (min or max).

Attributes: elemental

Returns: logical

fortran
function has_range(self) result(ranged)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

range_text ​

Return the range as text: (0, 1], [1, +inf), ...

Attributes: pure

Returns: character(len=:)

fortran
function range_text(self) result(text)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

has_path_checks ​

Check if the value is a path to check (must_exist, readable or writable).

Attributes: elemental

Returns: logical

fortran
function has_path_checks(self) result(checks)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

takes_config_value ​

Check if the CLA takes a value from a configuration file: a named store (lists included), store_true or store_false.

Attributes: pure

Returns: logical

fortran
function takes_config_value(self) result(takes)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

match_token ​

Check if a command line token names this CLA: the one matcher of switch names (decision D1 of #125).

Rule 1: the token is the switch, its abbreviation or its negation (F11); blanks around both are not significant. A positional never matches. Rule 2 (NAME=VALUE) is match_inline_token, built on this one; match_negation tells which. With case_insensitive (F14, inherited from the CLI) the names match in any case.

Attributes: pure

Returns: logical

fortran
function match_token(self, token) result(match)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.
tokencharacter(len=*)inCommand line token.

Call graph

match_negation ​

Check if a command line token is the negation of this flag (switch_neg, F11 of #125), by rule 1 of match_token.

Attributes: pure

Returns: logical

fortran
function match_negation(self, token) result(match)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.
tokencharacter(len=*)inCommand line token.

Call graph

same_name ​

Compare a switch name with a token, blanks around them not significant; in any case with case_insensitive (F14).

Attributes: pure

Returns: logical

fortran
function same_name(self, name, token) result(same)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.
namecharacter(len=*)inSwitch name.
tokencharacter(len=*)inCommand line token.

Call graph

is_pair_override ​

Check if a flag already passed may be passed again: the other spelling of a flag pair, not yet passed (D5 of #125).

Attributes: pure

Returns: logical

fortran
function is_pair_override(self, negated) result(override)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.
negatedlogicalinThe token is the negation.

Call graph

names ​

Return the switch names of a visible named CLA (switch, abbreviation, negation), for the suggestions of F10.

Attributes: pure

Returns: type(flap_string)

fortran
function names(self) result(list)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

placeholder ​

Return the placeholder of the value in the usage and help (F12 of #125): the metavar if given (not blank), otherwise 'KEY=VALUE' for a map and 'value' for any other CLA.

Attributes: pure

Returns: character(len=:)

fortran
function placeholder(self) result(ph)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

flag_value ​

Return the value of a flag passed on the command line: .true. for store_true (.false. for store_false), the opposite when the last spelling passed is the negation (F11 of #125).

Attributes: pure

Returns: logical

fortran
function flag_value(self) result(val)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

is_repeatable ​

Check if the CLA may be passed more than once (count).

Attributes: pure

Returns: logical

fortran
function is_repeatable(self) result(repeatable)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

is_builtin ​

Check if the CLA is a builtin added by FLAP: --help, --version, --markdown, --man and the completion options (the hidden -- is recognised by its switch). Builtins are neither reported by provenance nor copied by copy_options.

Attributes: pure

Returns: logical

fortran
function is_builtin(self) result(builtin)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

is_list ​

Check if the CLA holds a list: nargs, or the append action.

Attributes: pure

Returns: logical

fortran
function is_list(self) result(list)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

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: dispatch to the renderer of the requested output.

Usage text: signature_usage; bash completion: completion_words (plain) or completion_values.

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

signature_usage ​

Get the signature for the usage text (human readable): the only place for rendering changes such as metavars.

A bare signature has no optional brackets, as a member of a mutually exclusive set, where the set is bracketed.

Returns: character(len=:)

fortran
function signature_usage(self, bare) result(signature)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.
barelogicalinoptionalRender without optional brackets.

Call graph

completion_words ​

Get the bash completion words of a named CLA: its switches, blank separated (none for positional or hidden CLAs).

Returns: character(len=:)

fortran
function completion_words(self) result(words)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

completion_offer ​

Get the bash lines adding the completion words of a named CLA to words (B37 of #125): unless repeatable (append, count), a spelling already typed (used: the words of its group so far, --x or --x=value) is not offered again; the switch and its abbreviation are one spelling, a negation is another (D5). None for positional or hidden CLAs.

Returns: character(len=:)

fortran
function completion_offer(self) result(lines)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

completion_fish ​

Get the fish completion lines of a named CLA (F15 of #125): each starts with a new line and head (complete -c prog and its condition). Long switches are -l, one-letter ones -s, multi-letter single-dash ones old-style -o; choices are offered exclusively (-x -a), a free value completes file names (-r -F), a flag takes none; a negation has its own line. None for positional or hidden CLAs.

Returns: character(len=:)

fortran
function completion_fish(self, head) result(lines)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.
headcharacter(len=*)inBeginning of each line.

Call graph

completion_powershell ​

Get the PowerShell completion entries of a named CLA (F15 of #125), one per switch name, each on its own line: @{ n = name; d = help; c = choices or $null; v = takes a value }. A negation takes no value. None for positional or hidden CLAs.

Returns: character(len=:)

fortran
function completion_powershell(self) result(entries)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph

completion_values ​

Get the bash completion of the value following a named CLA: a prev test offering its choices, or nothing for a value.

Returns: character(len=:)

fortran
function completion_values(self) result(values)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

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: a list without values (or with a single blank one) is empty.

Returns: logical

fortran
function check_list_size(self, vals, pref) result(is_ok)

Arguments

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

Call graph

stored_list ​

Return the stored list of values: the resolved one if given by the user (has_value), the default one otherwise.

Returns: character(len=:)

fortran
function stored_list(self) result(list)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_argument)inCLA data.

Call graph