-
Notifications
You must be signed in to change notification settings - Fork 34
Custom CLI help message
CLI data type can already (quasi-automatically) handle CLAs through its default values (provided from the baseline variable declaration, i.e. type(command_line_interface):: cli
). However, in order to improve the clearness of CLI messages you can personalized help messages by means of init method (that remains an optional step):
call cli%init(progname, version, help, description, license, authors, examples, epilog, disable_hv)
where
character(*), optional, intent(in) :: progname !< Program name.
character(*), optional, intent(in) :: version !< Program version.
character(*), optional, intent(in) :: help !< Help message introducing the CLI usage.
character(*), optional, intent(in) :: description !< Detailed description message introducing the program.
character(*), optional, intent(in) :: license !< License description.
character(*), optional, intent(in) :: authors !< Authors list.
character(*), optional, intent(in) :: examples(1:) !< Examples of correct usage.
character(*), optional, intent(in) :: epilog !< Epilog message.
logical, optional, intent(in) :: disable_hv !< Disable automatic inserting of 'help' and 'version' CLAs.
for more details see CLI-Method-init.
The dummy arguments should be auto-explicative. Note that the help and examples dummy arguments are used for printing a pretty help message explaining the CLI usage, thus should be always provided even if they are optional arguments. Moreover, due the Fortran limitations, the array containing the examples must have character elements with the same length, thus trailing white spaces must padded to short examples.
The only not so clear argument of init method is disable_hv.
FLAP automatically adds 2 special CLA to CLI:
- a CLA for printing a help message explaining the correct use of the CLI;
- a CLA for printing the version (if defined when the CLI is initialized) of the program.
This two CLAs has the following default switches:
-
help: switch
--help
, abbreviated switch-h
; -
version: switch
--version
, abbreviated switch-v
;
However, FLAP before adding these two CLAs to the CLI checks if these switches have been already used and in case does not add them. To disable such an automatic CLAs creation initialized the CLI with:
call cli%init(...,disable_hv=.true.)
Home | About | Getting Started Guide | Usage | Copyright © 2016 szaghi