Skip to content

CLI Method is_defined

Stefano Zaghi edited this page Mar 23, 2016 · 1 revision

is_defined

Signature

is_defined =  cli%is_defined(group, switch)
Meaning

Inquire if a CLA has been defined into the CLI.

Dummy arguments
character(*), optional, intent(in) :: group  !< Name of group (command) of CLAs.
character(*),           intent(in) :: switch !< Switch name.

Note that this is a pure function.

The following rules apply:

  • if no group is passed it assumed that the CLA belongs to the default (not named) one (group number 0);
  • switch is check with both switch and switch_ab definitions;
  • presently it is not possible to inquire the definition of positional CLA.
Usage

Must be used for inquiring if a CLA has been defined into the CLI

use flap

type(command_line_interface):: cli
logical::                      is_defined

call cli%init(...)
call cli%add(...)
call cli%parse(...)

is_defined = cli%is_defined(group='commit', switch='-m')
if (is_defined) then
  ! do your job with commit command message, e.g. check if it has been actually passed...
endif
Clone this wiki locally