Skip to content
Stefano Zaghi edited this page Mar 24, 2016 · 3 revisions

parse

Signature

call clI%parse(pref, args, error)
Meaning

Parse Command Line Interfaces. All dummy arguments are optional.

Dummy arguments
character(*), optional, intent(in)  :: pref  !< Prefixing string.
character(*), optional, intent(in)  :: args  !< String containing command line arguments.
integer(I4P), optional, intent(out) :: error !< Error trapping flag.

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

Usage

Must be used for parsing the arguments values passed to the program CLI invocation. Note that all the values are saved as strings during this phase (all leading and trailing white spaces are removed from the values): the casting to the user-actual-type is done from the get method. During this parsing the default (or environmental values) are flushed to the arguments values if necessary.

use flap

type(command_line_interface):: cli
integer::                      error

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

! parse the arguments values
call cli%parse(error=error) ; if (error/=0) stop
...

For trapping errors the dummy argument error can be used. The complete errors values are listed in Errors-codes.

Explicit call to parse is optional

Note that the explicit call to the parse method is optional: the first time you will call the get method, the parsed status of the CLI is checked and, if necessary, it automatically calls the parse one.

Clone this wiki locally