Skip to content

flap_command_line_interface_t ​

Command Line Interface (CLI) class.

Source: src/lib/flap_command_line_interface_t.F90

Dependencies

Contents ​

Variables ​

NameTypeAttributesDescription
ERROR_MISSING_CLAinteger(kind=I4P)parameterCLA not found in CLI.
ERROR_MISSING_GROUPinteger(kind=I4P)parameterGroup not found in CLI.
ERROR_MISSING_SELECTION_CLAinteger(kind=I4P)parameterCLA selection in CLI failing.
ERROR_TOO_FEW_CLASinteger(kind=I4P)parameterInsufficient arguments for CLI.
ERROR_UNKNOWN_CLAS_IGNOREDinteger(kind=I4P)parameterUnknown CLAs passed, but ignored.
ERROR_USERinteger(kind=I4P)parameterApplication error reported by raise_error.
ERROR_CONFIG_NOT_FOUNDinteger(kind=I4P)parameterRequired configuration file not found.
ERROR_CONFIG_UNKNOWN_KEYinteger(kind=I4P)parameterConfiguration file: unknown key or malformed line.
ERROR_GROUP_ALIASinteger(kind=I4P)parameterAlias of a command equal to a command or an alias.
ERROR_COPY_POSITIONALinteger(kind=I4P)parametercopy_options asked to copy a positional CLA.
ERROR_COMPLETION_SHELLinteger(kind=I4P)parameterUnknown (or unset) shell of the completion builtins.
ERROR_COMPLETION_INSTALLinteger(kind=I4P)parameterThe completion script cannot be installed.
ERROR_ARGUMENT_RETRIEVALinteger(kind=I4P)parameterA command line argument cannot be retrieved.
ERROR_COMMAND_REPEATEDinteger(kind=I4P)parameterA command passed more than once (B36).
ERROR_USAGE_ON_ERRORinteger(kind=I4P)parameterinit(usage_on_error=) not full, usage or none (F27).

Derived Types ​

command_line_interface ​

Command Line Interface (CLI) class.

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).
clasgtype(command_line_arguments_group)allocatableCLA list [1:Na].
argstype(flap_string)allocatableActually passed command line arguments.
disable_hvlogicalDisable automatic 'help' and 'version' CLAs.
is_parsed_logicalParse status.
ignore_unknown_claslogicalDisable errors-raising for passed unknown CLAs.
standalonelogicalStop after help/version/markdown.
error_hintlogicalPrint a hint after a failed parse.
no_args_is_helplogicalPrint the help when no arguments are passed.
ignore_envlogicalTurn every environment lookup off.
completion_optionslogical--show/--install-completion (F24).
auto_envvar_prefixcharacter(len=:)allocatablePrefix of the generated envvar names.
usage_on_errorcharacter(len=:)allocatableAfter an error: full, usage, none (F27).
man_optionlogical--man builtin (F29).
man_filecharacter(len=:)allocatableFile of --man ('': .1).
markdown_filecharacter(len=:)allocatableFile of --markdown ('': .md).
config_pathcharacter(len=:)allocatableConfiguration file (F08).
config_requiredlogicalThe configuration file must exist.
config_usedcharacter(len=:)allocatableConfiguration file read by parse.
error_unknown_clasinteger(kind=I4P)Error trapping flag for unknown CLAs.
unknown_messagecharacter(len=:)allocatableMessage of an ignored unknown CLA.

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.
initInitialize CLI.
add_groupAdd CLAs group CLI.
addAdd CLA to CLI.
is_passedCheck if a CLA has been passed.
is_defined_groupCheck if a CLAs group has been defined.
raise_errorReport an application error in FLAP's style.
is_definedCheck if a CLA has been defined.
is_parsedCheck if CLI has been parsed.
set_mutually_exclusive_groupsSet two CLAs group as mutually exclusive.
set_mutually_exclusive_switchesSet a mutually exclusive set of switches.
set_configSet the configuration file.
get_sourceSource of the value of a CLA.
provenanceReport of every value with its source.
run_commandCheck if a CLAs group has been run.
parseParse Command Line Interfaces.
reset_parseForget the result of a parse, keeping the definitions.
get_mapGet the keys and values of a map option (F18).
copy_optionsCopy the named options of a group into another (F21).
get_map_valueGet the value of a key of a map option (F18).
getGet CLA value(s) from CLAs list parsed.
get_varyingGet CLA value(s) from CLAs list parsed, varying size list.
usageGet CLI usage.
signatureGet CLI signature.
print_usagePrint correct usage of CLI.
save_bash_completionSave bash completion script (for named CLAs only).
save_zsh_completionSave zsh completion script (bash script via bashcompinit).
save_fish_completionSave fish completion script (native).
save_powershell_completionSave PowerShell completion script (native completer).
save_man_pageSave CLI usage as man page.
save_usage_to_markdownSave CLI usage as markdown.
ensure_builtinsAdd the builtin CLAs (help, markdown, version, --) if missing.
builtins_missingCheck if the builtin CLAs still have to be added.
usage_coreGet CLI usage (builtins already present).
signature_coreGet CLI signature (builtins already present).
completion_scriptCompletion script of a shell.
completion_script_coreCompletion script of a shell (builtins already present).
completion_shellShell of a completion builtin.
install_completionInstall the completion script of a shell.
bash_scriptBash (or zsh) completion script.
fish_scriptFish completion script.
powershell_scriptPowerShell completion script.
save_man_page_coreSave CLI usage as man page (builtins already present).
save_usage_to_markdown_coreSave CLI usage as markdown (builtins already present).
parse_coreParse the command line (body of parse).
group_indexIndex of the group with a name, -1 if none.
is_fatalCheck if the current error stops parsing.
dispatch_statusPrint help/version/markdown in the D3 order.
no_args_helpPrint the help when no arguments are passed.
print_error_hintPrint the hint after a failed parse.
erroredTrig error occurence and print meaningful message.
checkCheck data consistency.
check_m_exclusiveCheck if two mutually exclusive CLAs group have been called.
load_configLoad and check the configuration file.
warn_deprecatedWarn about the deprecated options and commands used.
get_clasg_indexesGet CLAs groups indexes.
print_usage_lineAfter an error: the usage line (F27).
usage_on_error_isCheck init(usage_on_error=) (F27).
get_argsGet CLAs.
get_args_from_stringGet CLAs from string.
get_args_from_invocationGet CLAs from CLI invocation.
get_claGet CLA (single) value from CLAs list parsed.
get_cla_listGet CLA multiple values from CLAs list parsed.
get_cla_list_varying_R16PGet CLA multiple values from CLAs list parsed, varying size, R16P.
get_cla_list_varying_R8PGet CLA multiple values from CLAs list parsed, varying size, R8P.
get_cla_list_varying_R4PGet CLA multiple values from CLAs list parsed, varying size, R4P.
get_cla_list_varying_I8PGet CLA multiple values from CLAs list parsed, varying size, I8P.
get_cla_list_varying_I4PGet CLA multiple values from CLAs list parsed, varying size, I4P.
get_cla_list_varying_I2PGet CLA multiple values from CLAs list parsed, varying size, I2P.
get_cla_list_varying_I1PGet CLA multiple values from CLAs list parsed, varying size, I1P.
get_cla_list_varying_logicalGet CLA multiple values from CLAs list parsed, varying size, bool.
get_cla_list_varying_charGet CLA multiple values from CLAs list parsed, varying size, char.
map_claLocate the CLA of a map getter.

Subroutines ​

free ​

Free dynamic memory.

Attributes: elemental

fortran
subroutine free(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.

Call graph

init ​

Initialize CLI.

fortran
subroutine init(self, progname, version, help, description, license, authors, examples, epilog, disable_hv, usage_lun, error_lun, version_lun, error_color, error_style, ignore_unknown_clas, standalone, error_hint, no_args_is_help, ignore_env, auto_envvar_prefix, case_insensitive, completion_options, usage_on_error, man_option, man_file, markdown_file)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
prognamecharacter(len=*)inoptionalProgram name.
versioncharacter(len=*)inoptionalProgram version.
helpcharacter(len=*)inoptionalHelp message introducing the CLI usage.
descriptioncharacter(len=*)inoptionalDetailed description message introducing the program.
licensecharacter(len=*)inoptionalLicense description.
authorscharacter(len=*)inoptionalAuthors list.
examplescharacter(len=*)inoptionalExamples of correct usage.
epilogcharacter(len=*)inoptionalEpilog message.
disable_hvlogicalinoptionalDisable automatic insert of 'help' and 'version' CLAs.
usage_luninteger(kind=I4P)inoptionalUnit number to print usage/help.
error_luninteger(kind=I4P)inoptionalUnit number to print error info.
version_luninteger(kind=I4P)inoptionalUnit number to print version/license info.
error_colorcharacter(len=*)inoptionalANSI color of error messages.
error_stylecharacter(len=*)inoptionalANSI style of error messages.
ignore_unknown_claslogicalinoptionalDisable errors-raising for passed unknown CLAs.
standalonelogicalinoptionalStop after help/version/markdown (default); if
error_hintlogicalinoptionalPrint "Try 'prog --help' for help." after a failed
no_args_is_helplogicalinoptionalPrint the help (STATUS_NO_ARGS) when no arguments
ignore_envlogicalinoptionalTurn every environment lookup off (F20): envvar
auto_envvar_prefixcharacter(len=*)inoptionalGenerate the envvar of the options without one:
case_insensitivelogicalinoptionalMatch switches and command names in any case (F14);
completion_optionslogicalinoptionalAdd --show-completion and --install-completion
usage_on_errorcharacter(len=*)inoptionalWhat an error prints after its message (F27):
man_optionlogicalinoptionalAdd --man to the top level (F29).
man_filecharacter(len=*)inoptionalFile of --man (default .1).
markdown_filecharacter(len=*)inoptionalFile of --markdown (default .md).

Call graph

add_group ​

Add CLAs group to CLI.

The aliases (F19 of #125) are comma separated: invoking an alias is invoking the command. An alias equal to a command name, to another alias, to the command itself, or blank, and a command name equal to an alias, are ERROR_GROUP_ALIAS: printed, returned, and kept on the command, so that parse fails too (as an invalid exclusive set).

fortran
subroutine add_group(self, help, description, exclude, examples, group, no_args_is_help, deprecated, aliases, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
helpcharacter(len=*)inoptionalHelp message.
descriptioncharacter(len=*)inoptionalDetailed description.
excludecharacter(len=*)inoptionalGroup name of the mutually exclusive group.
examplescharacter(len=*)inoptionalExamples of correct usage of the group.
groupcharacter(len=*)inName of the grouped CLAs.
no_args_is_helplogicalinoptionalPrint the help of the group when invoked alone.
deprecatedcharacter(len=*)inoptionalDeprecation message ('' for none): warn when called.
aliasescharacter(len=*)inoptionalAliases of the command, comma separated (F19).
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

set_mutually_exclusive_groups ​

Set two CLAs group ad mutually exclusive.

fortran
subroutine set_mutually_exclusive_groups(self, group1, group2)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
group1character(len=*)inName of the first grouped CLAs.
group2character(len=*)inName of the second grouped CLAs.

Call graph

set_config ​

Set the configuration file (F08 of #125): an INI file whose values come below the environment and above the defaults.

Read by parse, after help/version: keys are long switches without the dashes, sections are groups (commands). A missing file is skipped, unless required (ERROR_CONFIG_NOT_FOUND); an unknown key or a malformed line is ERROR_CONFIG_UNKNOWN_KEY, unless ignore_unknown_clas.

fortran
subroutine set_config(self, file, required, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
filecharacter(len=*)inFile name.
requiredlogicalinoptionalThe file must exist (default .false.).
errorinteger(kind=I4P)outoptionalError trapping flag.

warn_deprecated ​

Warn about the deprecated options and commands used (F13 of #125), on error_lun: a called command, an option whose value comes from the command line or the environment (not from a configuration file or the default, as in click).

fortran
subroutine warn_deprecated(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

load_config ​

Load the configuration file, if any, and check it: every key must name an option taking a value (D18 of #125).

The file is named by the top-level act='config' option when given on the command line or in its environment variable (then it must exist), else by set_config (which says if it must exist), else by the default of that option (skipped when missing).

fortran
subroutine load_config(self, config, pref, check)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
configtype(config_file)inoutConfiguration file.
prefcharacter(len=*)inoptionalPrefixing string.
checklogicalinoptionalReport a missing or invalid file (default .true.; off for an

Call graph

set_mutually_exclusive_switches ​

Set a mutually exclusive set of switches (F03 of #125): at most one member may be passed, exactly one if required.

The members (comma separated, by switch or abbreviation) must be already added to the group, not required, and in no other set; otherwise the set is not added and the error is ERROR_M_EXCLUDE_SET_DEFINITION. Only passed members count: a default neither satisfies nor violates a set.

fortran
subroutine set_mutually_exclusive_switches(self, switches, required, group, pref, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
switchescharacter(len=*)inComma separated members, e.g. '--mesh,--restart'.
requiredlogicalinoptionalExactly one member must be passed (default .false.).
groupcharacter(len=*)inoptionalGroup (command) of the members (default: the top level).
prefcharacter(len=*)inoptionalPrefixing string.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

add ​

Add CLA to CLI.

@note If not otherwise declared the action on CLA value is set to "store" a value that must be passed after the switch name or directly passed in case of positional CLA.

@note If not otherwise speficied the CLA belongs to the default group "zero" that is the group of non-grouped CLAs.

@note If CLA belongs to a not yet present group it is created on the fly.

fortran
subroutine add(self, pref, group, group_index, switch, switch_ab, switch_neg, help, help_markdown, help_color, help_style, required, val_required, positional, position, hidden, act, def, nargs, choices, exclude, envvar, must_exist, readable, writable, allow_dash, deprecated, min, max, min_open, max_open, clamp, case_sensitive, map, map_keys, metavar, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
prefcharacter(len=*)inoptionalPrefixing string.
groupcharacter(len=*)inoptionalName of the grouped CLAs.
group_indexinteger(kind=I4P)inoptionalIndex of the grouped CLAs.
switchcharacter(len=*)inoptionalSwitch name.
switch_abcharacter(len=*)inoptionalAbbreviated switch name.
switch_negcharacter(len=*)inoptionalNegation of a flag, --no-x (F11): the opposite value.
helpcharacter(len=*)inoptionalHelp message describing the CLA.
help_markdowncharacter(len=*)inoptionalLonger help message, markdown formatted.
help_colorcharacter(len=*)inoptionalANSI color of help messages.
help_stylecharacter(len=*)inoptionalANSI style of help messages.
requiredlogicalinoptionalFlag for set required argument.
val_requiredlogicalinoptionalFlag for set value required for optional argument.
positionallogicalinoptionalFlag for checking if CLA is a positional or a named CLA.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.
hiddenlogicalinoptionalFlag for hiding CLA, thus it does not compare into help.
actcharacter(len=*)inoptionalCLA value action.
defcharacter(len=*)inoptionalDefault value.
nargscharacter(len=*)inoptionalNumber of arguments consumed by CLA.
choicescharacter(len=*)inoptionalList of allowable values for the argument.
excludecharacter(len=*)inoptionalSwitch name of the mutually exclusive CLA.
envvarcharacter(len=*)inoptionalEnvironment variable from which take value.
must_existlogicalinoptionalThe value is a path that must exist (F09).
readablelogicalinoptionalThe value is a path that must be readable (and exist).
writablelogicalinoptionalThe value is a path writable if it exists.
allow_dashlogicalinoptional'-' passes the path checks (standard input/output).
deprecatedcharacter(len=*)inoptionalDeprecation message ('' for none): warn when used (F13).
mincharacter(len=*)inoptionalMinimum of the value (F05), checked by get.
maxcharacter(len=*)inoptionalMaximum of the value (F05), checked by get.
min_openlogicalinoptionalThe minimum is excluded (default .false.).
max_openlogicalinoptionalThe maximum is excluded (default .false.).
clamplogicalinoptionalAn out-of-range value becomes the bound (default .false.).
case_sensitivelogicalinoptionalCharacter choices match only in their case (default
maplogicalinoptionalThe values are KEY=VALUE pairs (F18).
map_keyscharacter(len=*)inoptionalAllowed keys of a map, comma separated (F18).
metavarcharacter(len=*)inoptionalPlaceholder of the value in the help (F12), default 'value'.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

check ​

Check data consistency.

fortran
subroutine check(self, pref, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
prefcharacter(len=*)inoptionalPrefixing string.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

check_m_exclusive ​

Check if two mutually exclusive CLAs group have been called.

fortran
subroutine check_m_exclusive(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

reset_parse ​

Forget the result of a parse, keeping the definitions (options, commands, builtins): the next parse (or get) parses again. Without it, a second call of parse is ignored and the first result is kept.

fortran
subroutine reset_parse(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.

Call graph

parse ​

Parse Command Line Interfaces by means of a previously initialized CLAs groups list.

@note The leading and trailing white spaces are removed from CLA values.

@note If the args argument is passed the command line arguments are taken from it and not from the actual program CLI invocations.

fortran
subroutine parse(self, pref, args, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

Print the last line after a failed parse: "Try 'prog [command] --help' for help." (F26 of #125).

Only when enabled (error_hint) and when there is a help option to suggest (not disable_hv); the command is the first called one with an error.

fortran
subroutine print_error_hint(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.

Call graph

parse_core ​

Parse the command line (the body of parse, which returns early once parsed and hands the error back).

fortran
subroutine parse_core(self, pref, args)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.

Call graph

install_completion ​

Install the completion script of a shell (F24 of #125): write it to HOME/.<prog>-completion.<shell>, then append a line sourcing it, marked '# FLAP completion: <prog>', to the shell's rc file (HOME/.bashrc, $HOME/.zshrc, $HOME/.config/fish/config.fish), only if the marker is absent: the rc file is never rewritten, no directory is created. Success is STATUS_INSTALL_COMPLETION (and a report on the version unit); a failure ERROR_COMPLETION_INSTALL (printed, with the I/O message); PowerShell is not installed (ERROR_COMPLETION_SHELL, with instructions).

fortran
subroutine install_completion(self, shell, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
shellcharacter(len=*)inShell: bash, zsh, fish or powershell.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

After an error of group g, with init(usage_on_error='usage') (F27): the usage line of its help, as --help shows it.

fortran
subroutine print_usage_line(self, pref, g)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
prefcharacter(len=*)inoptionalPrefixing string.
ginteger(kind=I4P)inGroup of the error.

Call graph

get_clasg_indexes ​

Get the argument indexes of each CLAs group (command): ai(g,1:2) is the slice of self%args belonging to group g.

Arguments before the first command name belong to group 0; the arguments after a command name belong to that command. The fixed value slots of a switch (value_arity) are skipped before testing for a command name, so a value equal to a command name stays a value (B04); a variadic list is ended by a command name. A command met again (by its name or an alias) is returned in repeated (its name and the spelling met), never restarted (B36: that dropped its values).

fortran
subroutine get_clasg_indexes(self, ai, repeated)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
aiinteger(kind=I4P)outallocatableCLAs grouped indexes.
repeatedtype(flap_string)outallocatableThe first command repeated, [name, spelling]; none if none.

Call graph

get_args_from_string ​

Get CLAs from string.

The string is split as a shell would split a command line: see split_command_line.

fortran
subroutine get_args_from_string(self, args, ai, repeated)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
argscharacter(len=*)inString containing command line arguments.
aiinteger(kind=I4P)outallocatableCLAs grouped indexes.
repeatedtype(flap_string)outallocatableThe first command repeated (see get_clasg_indexes).

Call graph

get_args_from_invocation ​

Get CLAs from CLI invocation.

Every argument is read whole: its length is queried first, and a failed retrieval raises ERROR_ARGUMENT_RETRIEVAL.

fortran
subroutine get_args_from_invocation(self, ai, repeated)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
aiinteger(kind=I4P)outallocatableCLAs grouped indexes.
repeatedtype(flap_string)outallocatableThe first command repeated (see get_clasg_indexes).

Call graph

get_cla ​

Get CLA (single) value from CLAs list parsed.

@note For logical type CLA the value is directly read without any robust error trapping.

fortran
subroutine get_cla(self, val, pref, args, group, switch, position, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
valclass(*)inoutCLA value.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
switchcharacter(len=*)inoptionalSwitch name.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

get_cla_list ​

Get CLA multiple values from CLAs list parsed.

@note For logical type CLA the value is directly read without any robust error trapping.

fortran
subroutine get_cla_list(self, val, pref, args, group, switch, position, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
valclass(*)inoutCLA values.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
switchcharacter(len=*)inoptionalSwitch name.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

get_cla_list_varying_R16P ​

Get CLA multiple values from CLAs list parsed with varying size list, real(R16P).

@note The CLA list is returned deallocated if values are not correctly gotten.

@note For logical type CLA the value is directly read without any robust error trapping.

fortran
subroutine get_cla_list_varying_R16P(self, val, pref, args, group, switch, position, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
valreal(kind=R16P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
switchcharacter(len=*)inoptionalSwitch name.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

get_cla_list_varying_R8P ​

Get CLA multiple values from CLAs list parsed with varying size list, real(R8P).

@note The CLA list is returned deallocated if values are not correctly gotten.

@note For logical type CLA the value is directly read without any robust error trapping.

fortran
subroutine get_cla_list_varying_R8P(self, val, pref, args, group, switch, position, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
valreal(kind=R8P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
switchcharacter(len=*)inoptionalSwitch name.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

get_cla_list_varying_R4P ​

Get CLA multiple values from CLAs list parsed with varying size list, real(R4P).

@note The CLA list is returned deallocated if values are not correctly gotten.

@note For logical type CLA the value is directly read without any robust error trapping.

fortran
subroutine get_cla_list_varying_R4P(self, val, pref, args, group, switch, position, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
valreal(kind=R4P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
switchcharacter(len=*)inoptionalSwitch name.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

get_cla_list_varying_I8P ​

Get CLA multiple values from CLAs list parsed with varying size list, integer(I8P).

@note The CLA list is returned deallocated if values are not correctly gotten.

@note For logical type CLA the value is directly read without any robust error trapping.

fortran
subroutine get_cla_list_varying_I8P(self, val, pref, args, group, switch, position, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
valinteger(kind=I8P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
switchcharacter(len=*)inoptionalSwitch name.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

get_cla_list_varying_I4P ​

Get CLA multiple values from CLAs list parsed with varying size list, integer(I4P).

@note The CLA list is returned deallocated if values are not correctly gotten.

@note For logical type CLA the value is directly read without any robust error trapping.

fortran
subroutine get_cla_list_varying_I4P(self, val, pref, args, group, switch, position, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
valinteger(kind=I4P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
switchcharacter(len=*)inoptionalSwitch name.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

get_cla_list_varying_I2P ​

Get CLA multiple values from CLAs list parsed with varying size list, integer(I2P).

@note The CLA list is returned deallocated if values are not correctly gotten.

@note For logical type CLA the value is directly read without any robust error trapping.

fortran
subroutine get_cla_list_varying_I2P(self, val, pref, args, group, switch, position, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
valinteger(kind=I2P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
switchcharacter(len=*)inoptionalSwitch name.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

get_cla_list_varying_I1P ​

Get CLA multiple values from CLAs list parsed with varying size list, integer(I1P).

@note The CLA list is returned deallocated if values are not correctly gotten.

@note For logical type CLA the value is directly read without any robust error trapping.

fortran
subroutine get_cla_list_varying_I1P(self, val, pref, args, group, switch, position, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
valinteger(kind=I1P)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
switchcharacter(len=*)inoptionalSwitch name.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

get_cla_list_varying_logical ​

Get CLA multiple values from CLAs list parsed with varying size list, logical.

@note The CLA list is returned deallocated if values are not correctly gotten.

@note For logical type CLA the value is directly read without any robust error trapping.

fortran
subroutine get_cla_list_varying_logical(self, val, pref, args, group, switch, position, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
vallogicaloutallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
switchcharacter(len=*)inoptionalSwitch name.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

copy_options ​

Copy named options of a group (default the top level) into another group (F21 of #125): by value, every definition and none of the runtime state, so each copy has its own value. Without switches, every named option but the builtins; with switches (comma separated), those, all checked before any copy. A generated envvar (auto_envvar_prefix) is generated again for the target group, an explicit one is copied verbatim. Errors: ERROR_MISSING_GROUP, ERROR_MISSING_CLA, ERROR_COPY_POSITIONAL, and the consistency error of the target group (a switch it defines).

fortran
subroutine copy_options(self, to_group, from_group, switches, pref, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
to_groupcharacter(len=*)inTarget group (command).
from_groupcharacter(len=*)inoptionalSource group (command), default the top level.
switchescharacter(len=*)inoptionalSwitches to copy, comma separated (default all).
prefcharacter(len=*)inoptionalPrefixing string.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

get_map ​

Get the keys and values of a map option (F18 of #125), in the order given; passed pairs replace the default ones.

fortran
subroutine get_map(self, switch, keys, values, group, pref, args, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
switchcharacter(len=*)inSwitch name.
keyscharacter(len=*)outallocatableKeys.
valuescharacter(len=*)outallocatableValues.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

get_map_value ​

Get the value of a key of a map option, converted to the type of val (F18 of #125). A missing key leaves val untouched: found=.false., or ERROR_MAP_KEY_MISSING when found is absent.

fortran
subroutine get_map_value(self, switch, key, val, found, group, pref, args, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
switchcharacter(len=*)inSwitch name.
keycharacter(len=*)inKey.
valclass(*)inoutValue.
foundlogicaloutoptionalThe key is in the map.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

get_cla_list_varying_char ​

Get CLA multiple values from CLAs list parsed with varying size list, character.

@note The CLA list is returned deallocated if values are not correctly gotten.

@note For logical type CLA the value is directly read without any robust error trapping.

fortran
subroutine get_cla_list_varying_char(self, val, pref, args, group, switch, position, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
valcharacter(len=*)outallocatableCLA values.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
switchcharacter(len=*)inoptionalSwitch name.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

ensure_builtins ​

Add the builtin CLAs if not done by the user: --help, --markdown and --version (unless disabled) and the hidden "--" collecting trailing arguments, in every group. Idempotent.

Called by parse and, on a copy, by every output method (usage, signature, save_*), so that their output is the same before and after parse (#125, B09).

fortran
subroutine ensure_builtins(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

save_bash_completion ​

Save bash completion script (for named CLAs only), builtins included whether or not parse has been called.

fortran
subroutine save_bash_completion(self, bash_file, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
bash_filecharacter(len=*)inOutput file name of bash completion script.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

save_zsh_completion ​

Save zsh completion script (F15 of #125): the bash script behind zsh's bashcompinit, to be sourced (e.g. from .zshrc); builtins included whether or not parse has been called.

fortran
subroutine save_zsh_completion(self, zsh_file, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
zsh_filecharacter(len=*)inOutput file name of zsh completion script.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

save_fish_completion ​

Save fish completion script (F15 of #125), native: switches, choices, file names for free values, commands and aliases; builtins included whether or not parse has been called. Install it as ~/.config/fish/completions/prog.fish.

fortran
subroutine save_fish_completion(self, fish_file, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
fish_filecharacter(len=*)inOutput file name of fish completion script.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

save_powershell_completion ​

Save PowerShell completion script (F15 of #125): a native argument completer (see powershell_script); builtins included whether or not parse has been called. Dot-source it, e.g. from $PROFILE.

fortran
subroutine save_powershell_completion(self, powershell_file, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
powershell_filecharacter(len=*)inOutput file name of PowerShell completion script.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

save_man_page ​

Save CLI usage as man page, builtins included whether or not parse has been called.

fortran
subroutine save_man_page(self, man_file, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
man_filecharacter(len=*)inOutput file name for saving man page.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

save_usage_to_markdown ​

Save CLI usage as markdown, builtins included whether or not parse has been called.

fortran
subroutine save_usage_to_markdown(self, markdown_file, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
markdown_filecharacter(len=*)inOutput file name for saving markdown.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

Print correct usage.

fortran
subroutine print_usage(self, pref)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

save_man_page_core ​

Save CLI usage as man page.

fortran
subroutine save_man_page_core(self, man_file, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
man_filecharacter(len=*)inOutput file name for saving man page.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

save_usage_to_markdown_core ​

Save CLI usage as markdown.

fortran
subroutine save_usage_to_markdown_core(self, markdown_file, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
markdown_filecharacter(len=*)inOutput file name for saving man page.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

errored ​

Trig error occurrence and print meaningful message.

fortran
subroutine errored(self, error, pref, group, switch, position)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutObject data.
errorinteger(kind=I4P)inError occurred.
prefcharacter(len=*)inoptionalPrefixing string.
groupcharacter(len=*)inoptionalGroup name.
switchcharacter(len=*)inoptionalCLA switch name.
positioninteger(kind=I4P)inoptionalPosition of the command line argument.

Call graph

finalize ​

Free dynamic memory when finalizing.

Attributes: elemental

fortran
subroutine finalize(self)

Arguments

NameTypeIntentAttributesDescription
selftype(command_line_interface)inoutCLI data.

quiet_stop ​

End the program with an exit status, printing nothing (help/version/markdown: 0; no arguments: 2).

F2018 stop code, quiet=.true.; nvfortran 26.5 rejects quiet= and prints "FORTRAN STOP" on a plain stop, so it uses its exit extension (B33 of #125).

fortran
subroutine quiet_stop(code)

Arguments

NameTypeIntentAttributesDescription
codeinteger(kind=I4P)inExit status.

Call graph

write_script ​

Write a script (or any text) to a file. With error, a failure is reported (and its message in iomsg); without, it stops the program as any unchecked Fortran I/O.

fortran
subroutine write_script(file, script, error, iomsg)

Arguments

NameTypeIntentAttributesDescription
filecharacter(len=*)inFile name.
scriptcharacter(len=*)inText.
errorinteger(kind=I4P)outoptionalError trapping flag.
iomsgcharacter(len=:)outallocatable, optionalMessage of a failure.

Call graph

Functions ​

get_source ​

Return the source of the value of a CLA (SOURCE_COMMANDLINE, _ENVIRONMENT, _CONFIG, _DEFAULT, _NONE; F06 of #125).

Like get, it parses first if parse has not been called; an undefined CLA or group returns SOURCE_NONE with the error.

Returns: integer(kind=I4P)

fortran
function get_source(self, group, switch, position, pref, error) result(source)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
switchcharacter(len=*)inoptionalSwitch name.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.
prefcharacter(len=*)inoptionalPrefixing string.
errorinteger(kind=I4P)outoptionalError trapping flag.

Call graph

provenance ​

Return a report of every value with its source, for a run log (F06 of #125): one line per visible option of the top level and of the called commands, name = value [source], the environment and configuration sources naming their variable and file. Builtins and hidden options are left out; like get, it parses first if parse has not been called.

Returns: character(len=:)

fortran
function provenance(self, pref) result(report)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

envvar_name ​

Return the generated name of an environment variable: PREFIX[_GROUP]NAME, upper case, NAME being the switch without its leading dashes, '-' becoming '' (auto_envvar_prefix, F07 of #125; click's rule).

Attributes: pure

Returns: character(len=:)

fortran
function envvar_name(prefix, group, switch) result(name)

Arguments

NameTypeIntentAttributesDescription
prefixcharacter(len=*)inPrefix.
groupcharacter(len=*)inGroup (command), '' for the top level.
switchcharacter(len=*)inSwitch.

Call graph

is_passed ​

Check if a CLA has been passed.

Returns: logical

fortran
function is_passed(self, group, switch, position)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
switchcharacter(len=*)inoptionalSwitch name.
positioninteger(kind=I4P)inoptionalPosition of positional CLA.

Call graph

is_defined_group ​

Check if a CLAs group has been defined.

Returns: logical

fortran
function is_defined_group(self, group, g) result(defined)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
groupcharacter(len=*)inName of group (command) of CLAs.
ginteger(kind=I4P)outoptionalIndex of group, -1 if not defined.

Call graph

group_index ​

Return the index of the group (command) with a name, -1 if there is none: the one resolver of group names.

The top level is the group 0, named ''. A command matches by its name or an alias (F19); trailing blanks are not significant; the match is case sensitive, in any case with case_insensitive (F14).

Attributes: pure

Returns: integer(kind=I4P)

fortran
function group_index(self, name) result(g)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
namecharacter(len=*)inName of group (command).

Call graph

raise_error ​

Report an application error in FLAP's style (prefix, colours, error unit) and return ERROR_USER; never stop (F17 of #125).

For validation only the application can do (e.g. "--nx must be even"); by default the help (of group) follows the message, as init(usage_on_error=) chooses (the whole help, its usage line, nothing). An undefined group returns ERROR_MISSING_GROUP and prints nothing.

Returns: integer(kind=I4P)

fortran
function raise_error(self, message, switch, group, show_usage) result(error)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
messagecharacter(len=*)inError message.
switchcharacter(len=*)inoptionalOffending switch, prefixing the message.
groupcharacter(len=*)inoptionalGroup (command) whose usage is printed (default: top level).
show_usagelogicalinoptionalPrint the usage after the message (default .true.).

Call graph

is_called_group ​

Check if a CLAs group has been run.

Returns: logical

fortran
function is_called_group(self, group) result(called)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
groupcharacter(len=*)inName of group (command) of CLAs.

Call graph

is_defined ​

Check if a CLA has been defined.

Returns: logical

fortran
function is_defined(self, switch, group)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
switchcharacter(len=*)inSwitch name.
groupcharacter(len=*)inoptionalName of group (command) of CLAs.

Call graph

is_parsed ​

Check if CLI has been parsed.

Attributes: elemental

Returns: logical

fortran
function is_parsed(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.

no_args_help ​

Print the help when no arguments are passed (no_args_is_help), or when a command with the flag is invoked alone.

The status is STATUS_NO_ARGS; in standalone mode (default) the program ends with exit status 2 (a usage error, as in click), silently (quiet_stop).

Returns: logical

fortran
function no_args_help(self, ai, pref) result(printed)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
aiinteger(kind=I4P)inCLAs grouped indexes.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

dispatch_status ​

Print the help (of the first group that asked for it), the version or the markdown, in this order (D3 of #125).

In standalone mode (default) the program stops; otherwise the status is left in self%error for parse to return.

Returns: logical

fortran
function dispatch_status(self, pref) result(dispatched)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

completion_shell ​

Return the shell of a completion builtin (F24 of #125): its value, else the basename of $SHELL; pwsh is powershell. An unknown or unset shell is ERROR_COMPLETION_SHELL (printed), and '' is returned.

Returns: character(len=:)

fortran
function completion_shell(self, act, pref) result(shell)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
actcharacter(len=*)inAction of the builtin.
prefcharacter(len=*)inoptionalPrefixing string.

Call graph

usage_on_error_is ​

Check init(usage_on_error=) (F27; any case, 'full' when unset).

Returns: logical

fortran
function usage_on_error_is(self, mode) result(is)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
modecharacter(len=*)in'FULL', 'USAGE' or 'NONE'.

Call graph

is_fatal ​

Check if the current error stops parsing: any error but an unknown argument that is ignored (then recorded as such).

Returns: logical

fortran
function is_fatal(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.

Call graph

map_cla ​

Locate the CLA of a map getter, parsing first if needed: false (with the error set) if the parse failed or the group or the switch is not defined.

Returns: logical

fortran
function map_cla(self, switch, group, pref, args, g, a) result(ok)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inoutCLI data.
switchcharacter(len=*)inSwitch name.
groupcharacter(len=*)inoptionalName of group (command) of CLA.
prefcharacter(len=*)inoptionalPrefixing string.
argscharacter(len=*)inoptionalString containing command line arguments.
ginteger(kind=I4P)outIndex of the group.
ainteger(kind=I4P)outIndex of the CLA.

Call graph

builtins_missing ​

Check if the builtin CLAs still have to be added (the hidden "--" is added last, in every group).

Returns: logical

fortran
function builtins_missing(self) result(missing)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.

Call graph

usage ​

Get CLI usage, builtins included whether or not parse has been called.

Returns: character(len=:)

fortran
function usage(self, g, pref, no_header, no_examples, no_epilog, markdown) result(usaged)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
ginteger(kind=I4P)inGroup index.
prefcharacter(len=*)inoptionalPrefixing string.
no_headerlogicalinoptionalAvoid insert header to usage.
no_exampleslogicalinoptionalAvoid insert examples to usage.
no_epiloglogicalinoptionalAvoid insert epilogue to usage.
markdownlogicalinoptionalFormat things with markdown

Call graph

signature ​

Get CLI signature, builtins included whether or not parse has been called.

Returns: character(len=:)

fortran
function signature(self, bash_completion)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
bash_completionlogicalinoptionalReturn the signature for bash completion.

Call graph

completion_script ​

Return the completion script of a shell (bash, zsh, fish, powershell; '' for another), builtins included whether or not parse has been called (F15, F24 of #125).

Returns: character(len=:)

fortran
function completion_script(self, shell) result(script)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
shellcharacter(len=*)inShell.

Call graph

completion_script_core ​

Return the completion script of a shell (builtins already present).

Returns: character(len=:)

fortran
function completion_script_core(self, shell) result(script)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
shellcharacter(len=*)inShell.

Call graph

fish_script ​

Return the fish completion script (F15 of #125): one complete line per option, commands and aliases first.

Returns: character(len=:)

fortran
function fish_script(self) result(script)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.

Call graph

powershell_script ​

Return the PowerShell completion script (F15 of #125): a native argument completer with the tables of the commands (names and aliases) and of the options of each group; it completes the choices after an option, nothing after another option taking a value (PowerShell then completes paths), otherwise the options and, at the top level, the commands.

Returns: character(len=:)

fortran
function powershell_script(self) result(script)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.

Call graph

usage_core ​

Print correct usage of CLI.

Returns: character(len=:)

fortran
function usage_core(self, g, pref, no_header, no_examples, no_epilog, markdown) result(usaged)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
ginteger(kind=I4P)inGroup index.
prefcharacter(len=*)inoptionalPrefixing string.
no_headerlogicalinoptionalAvoid insert header to usage.
no_exampleslogicalinoptionalAvoid insert examples to usage.
no_epiloglogicalinoptionalAvoid insert epilogue to usage.
markdownlogicalinoptionalFormat things with markdown

Call graph

signature_core ​

Get signature.

Returns: character(len=:)

fortran
function signature_core(self, bash_completion) result(signature)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
bash_completionlogicalinoptionalReturn the signature for bash completion.

Call graph

bash_script ​

Return the bash completion script (for named CLAs only), registered with complete -o default (an empty completion falls back to file names, F15 of #125); with zsh, the same script behind zsh's bashcompinit.

Returns: character(len=:)

fortran
function bash_script(self, zsh) result(script)

Arguments

NameTypeIntentAttributesDescription
selfclass(command_line_interface)inCLI data.
zshlogicalinThe zsh script.

Call graph

completion_function ​

Name of the bash (and zsh) completion function of a program, _<basename>_completion, the basename made an identifier (any character but a letter, a digit or _ becomes _): one function per program, so that two FLAP programs complete in the same shell (B41 of #126).

Attributes: pure

Returns: character(len=:)

fortran
function completion_function(progname) result(name)

Arguments

NameTypeIntentAttributesDescription
prognamecharacter(len=*)inProgram name.

Call graph

program_basename ​

Return the program name without its path (separated by '/' or a backslash).

Attributes: pure

Returns: character(len=:)

fortran
function program_basename(progname) result(basename)

Arguments

NameTypeIntentAttributesDescription
prognamecharacter(len=*)inProgram name.

Call graph