-
Notifications
You must be signed in to change notification settings - Fork 34
CLI Method get_varying
Stefano Zaghi edited this page Mar 24, 2016
·
3 revisions
Signature
call cli%get_varying(val, pref, args, group, switch, position, error)
Get (retrieve) CLA list value(s) with varying list-size from CLAs values previously parsed.
class(*), allocatable, intent(out) :: val !< CLA value.
character(*), optional, intent(in) :: pref !< Prefixing string.
character(*), optional, intent(in) :: args !< String containing command line arguments.
character(*), optional, intent(in) :: group !< Name of group (command) of CLAs.
character(*), optional, intent(in) :: switch !< Switch name.
integer(I4P), optional, intent(in) :: position !< Position of positional CLA.
integer(I4P), optional, intent(out) :: error !< Error trapping flag.
Note that the dummy argument val
is an allocatable array with intent(OUT)
attribute, thus it is deallocated entering into the procedure.
Note that the CLA value is retrieved by means of an unlimited polymorphic class, thus the following types are the only presently supported:
- reals, of any kind;
- integers, of any kind;
- strings;
- logical, of the default kind.
The following rules apply:
- if
cli%parse(...)
is not been called before it is automatically called bycli%get
: the optional argumentargs
is passed fromcli%get
tocli%parse
; - 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 eventualposition
passed is not used;switch
is checked with bothswitch
andswitch_ab
definitions; -
position
must be passed for positional CLA; - for optional (not required) CLA, the default value is used if the CLA has not been passed;
- the CLA attribute
choiches
cannot be applied.
Must be used for getting (retrieving) a CLA value
use flap
type(command_line_interface):: cli
character(500), allocatable:: mylist(:)
integer:: error
call cli%init(...)
call cli%add(...)
call cli%parse(...)
! getting the actual CLAs value
call cli%get(group='commit',&
switch='-m', &
val=mylist, &
error=error)
if (error/=0) then
stop
else
print "(A)", "My list"
do l=1, size(mylist, dim=1)
print "(A)", mylist(l)
enddo
endif
For trapping errors the dummy argument error
can be used. The complete errors values are listed in Errors-codes.
Home | About | Getting Started Guide | Usage | Copyright © 2016 szaghi