Initialize CLI.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_interface), | intent(inout) | :: | self |
CLI data. |
||
character(len=*), | intent(in), | optional | :: | progname |
Program name. |
|
character(len=*), | intent(in), | optional | :: | version |
Program version. |
|
character(len=*), | intent(in), | optional | :: | help |
Help message introducing the CLI usage. |
|
character(len=*), | intent(in), | optional | :: | description |
Detailed description message introducing the program. |
|
character(len=*), | intent(in), | optional | :: | license |
License description. |
|
character(len=*), | intent(in), | optional | :: | authors |
Authors list. |
|
character(len=*), | intent(in), | optional | :: | examples(1:) |
Examples of correct usage. |
|
character(len=*), | intent(in), | optional | :: | epilog |
Epilog message. |
|
logical, | intent(in), | optional | :: | disable_hv |
Disable automatic insert of ‘help’ and ‘version’ CLAs. |
|
integer(kind=I4P), | intent(in), | optional | :: | usage_lun |
Unit number to print usage/help. |
|
integer(kind=I4P), | intent(in), | optional | :: | error_lun |
Unit number to print error info. |
|
integer(kind=I4P), | intent(in), | optional | :: | version_lun |
Unit number to print version/license info. |
|
character(len=*), | intent(in), | optional | :: | error_color |
ANSI color of error messages. |
|
character(len=*), | intent(in), | optional | :: | error_style |
ANSI style of error messages. |
|
logical, | intent(in), | optional | :: | ignore_unknown_clas |
Disable errors-raising for passed unknown CLAs. |
subroutine init(self, progname, version, help, description, license, authors, examples, epilog, disable_hv, & usage_lun, error_lun, version_lun, error_color, error_style, ignore_unknown_clas) !< Initialize CLI. class(command_line_interface), intent(inout) :: self !< CLI data. 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 insert of 'help' and 'version' CLAs. integer(I4P), optional, intent(in) :: usage_lun !< Unit number to print usage/help. integer(I4P), optional, intent(in) :: version_lun !< Unit number to print version/license info. integer(I4P), optional, intent(in) :: error_lun !< Unit number to print error info. character(*), optional, intent(in) :: error_color !< ANSI color of error messages. character(*), optional, intent(in) :: error_style !< ANSI style of error messages. logical, optional, intent(in) :: ignore_unknown_clas !< Disable errors-raising for passed unknown CLAs. character(len=:), allocatable :: prog_invocation !< Complete program invocation. integer(I4P) :: invocation_length !< Length of invocation. integer(I4P) :: retrieval_status !< Retrieval status. call self%free if (present(progname)) then self%progname = progname else ! try to set the default progname to the 0th command line entry a-la unix $0 call get_command_argument(0, length=invocation_length) allocate(character(len=invocation_length) :: prog_invocation) call get_command_argument(0, value=prog_invocation, status=retrieval_status) if (retrieval_status==0) then self%progname = prog_invocation else self%progname = 'program' endif endif self%version = 'unknown' ; if (present(version )) self%version = version self%help = 'usage: ' ; if (present(help )) self%help = help self%description = '' ; if (present(description)) self%description = description self%license = '' ; if (present(license )) self%license = license self%authors = '' ; if (present(authors )) self%authors = authors call self%set_examples(examples) self%epilog = '' ; if (present(epilog )) self%epilog = epilog if (present(disable_hv )) self%disable_hv = disable_hv ! default set by self%free if (present(usage_lun )) self%usage_lun = usage_lun ! default set by self%free if (present(version_lun)) self%version_lun = version_lun ! default set by self%free if (present(error_lun )) self%error_lun = error_lun ! default set by self%free self%error_color = '' ; if (present(error_color)) self%error_color = error_color self%error_style = '' ; if (present(error_style)) self%error_style = error_style if (present(ignore_unknown_clas)) self%ignore_unknown_clas = ignore_unknown_clas! default set by self%free ! initialize only the first default group allocate(self%clasg(0:0)) call self%clasg(0)%assign_object(self) self%clasg(0)%group = '' endsubroutine init