Skip to content

CLI Method is_passed

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

is_passed

Signature

is_passed = cli%is_passed(group, switch, position)
Meaning

Inquire if a CLA has been actually passed to CLI. All dummy arguments are optionals.

Dummy arguments
character(*), optional, intent(in) :: group    !< Name of group (command) of CLA.
character(*), optional, intent(in) :: switch   !< Switch name.
integer(I4P), optional, intent(in) :: position !< Position of positional CLA.

The following rules apply:

  • if no group is passed it assumed that the CLA belongs to the default (not named) one (group number 0);
  • if switch name is passed, the eventual position passed is not used; switch is checked with both switch and switch_ab definitions;
  • position must be passed for positional CLA.
Usage

Must be used for inquiring if a CLA has been passed to CLI

use flap

type(command_line_interface):: cli
logical::                      is_passed

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

is_passed = cli%is_passed(group='commit', switch='-m')
if (is_passed) then
  ! do your job with commit message
endif
! or inquire on the fly
if (cli%is_passed(switch='--integer')) print "(A)", ' Integer value has been passed!'
Clone this wiki locally