Command Line Arguments Group (CLAsG) class.
CLAsG are useful for building nested commands.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=:), | public, | allocatable | :: | progname |
Program name. |
||
character(len=:), | public, | allocatable | :: | version |
Program version. |
||
character(len=:), | public, | allocatable | :: | help |
Help message. |
||
character(len=:), | public, | allocatable | :: | help_color |
ANSI color of help messages. |
||
character(len=:), | public, | allocatable | :: | help_style |
ANSI style of help messages. |
||
character(len=:), | public, | allocatable | :: | help_markdown |
Longer help message, markdown formatted. |
||
character(len=:), | public, | allocatable | :: | description |
Detailed description. |
||
character(len=:), | public, | allocatable | :: | license |
License description. |
||
character(len=:), | public, | allocatable | :: | authors |
Authors list. |
||
character(len=:), | public, | allocatable | :: | epilog |
Epilogue message. |
||
character(len=:), | public, | allocatable | :: | m_exclude |
Mutually exclude other CLA(s group). |
||
character(len=:), | public, | allocatable | :: | error_message |
Meaningful error message to standard-error. |
||
character(len=:), | public, | allocatable | :: | error_color |
ANSI color of error messages. |
||
character(len=:), | public, | allocatable | :: | error_style |
ANSI style of error messages. |
||
character(len=512), | public, | allocatable | :: | examples(:) |
Examples of correct usage. |
||
integer(kind=I4P), | public | :: | error | = | 0_I4P |
Error trapping flag. |
|
integer(kind=I4P), | public | :: | usage_lun | = | stderr |
Output unit to print help/usage messages |
|
integer(kind=I4P), | public | :: | version_lun | = | stdout |
Output unit to print version message |
|
integer(kind=I4P), | public | :: | error_lun | = | stderr |
Error unit to print error messages |
|
character(len=:), | public, | allocatable | :: | group |
Group name (command). |
||
integer(kind=I4P), | public | :: | Na | = | 0_I4P |
Number of CLA. |
|
integer(kind=I4P), | private | :: | Na_required | = | 0_I4P |
Number of required command line arguments. |
|
integer(kind=I4P), | private | :: | Na_optional | = | 0_I4P |
Number of optional command line arguments. |
|
type(command_line_argument), | public, | allocatable | :: | cla(:) |
CLA list [1:Na]. |
||
logical, | public | :: | is_called | = | .false. |
Flag for checking if CLAs group has been passed to CLI. |
Free dynamic memory when finalizing.
Free dynamic memory when finalizing.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(command_line_arguments_group), | intent(inout) | :: | self |
CLAsG data. |
Free dynamic memory.
Free dynamic memory.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(object), | intent(inout) | :: | self |
Object data. |
Print version.
Print version.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(object), | intent(in) | :: | self |
Object data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Print meaningful error message.
Print meaningful error message to standard-error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(object), | intent(in) | :: | self |
Object data. |
Set examples of correct usage.
Set examples of correct usage.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(object), | intent(inout) | :: | self |
Object data. |
||
character(len=*), | intent(in), | optional | :: | examples(1:) |
Examples of correct usage. |
Assignment overloading.
Assign two abstract objects.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(object), | intent(inout) | :: | lhs |
Left hand side. |
||
class(object), | intent(in) | :: | rhs |
Rigth hand side. |
Free dynamic memory.
Free dynamic memory.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(inout) | :: | self |
CLAsG data. |
Check data consistency.
Check data consistency.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(inout) | :: | self |
CLAsG data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Check if required CLAs are passed.
Check if required CLAs are passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(inout) | :: | self |
CLAsG data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Check if a CLA has been passed.
Check if a CLA has been passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(in) | :: | self |
CLAsG data. |
||
character(len=*), | intent(in), | optional | :: | switch |
Switch name. |
|
integer(kind=I4P), | intent(in), | optional | :: | position |
Position of positional CLA. |
Check if a CLA has been passed.
Check if a CLA has been defined.
Check if a CLA has been defined.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(in) | :: | self |
CLAsG data. |
||
character(len=*), | intent(in) | :: | switch |
Switch name. |
||
integer(kind=I4P), | intent(out), | optional | :: | pos |
CLA position. |
Check if a CLA has been defined.
Raise error mutually exclusive CLAs passed.
Raise error mutually exclusive CLAs passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(inout) | :: | self |
CLA data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Add CLA to CLAsG.
Add CLA to CLAs list.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(inout) | :: | self |
CLAsG data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
|
type(command_line_argument), | intent(in) | :: | cla |
CLA data. |
Parse CLAsG arguments.
Parse CLAsG arguments.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(inout) | :: | self |
CLAsG data. |
||
character(len=*), | intent(in) | :: | args(:) |
Command line arguments. |
||
logical, | intent(in) | :: | ignore_unknown_clas |
Disable errors-raising for passed unknown CLAs. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
|
integer(kind=I4P), | intent(out) | :: | error_unknown_clas |
Error flag for passed unknown CLAs. |
Get correct CLAsG usage.
Get correct CLAsG usage.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(in) | :: | self |
CLAsG data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
|
logical, | intent(in), | optional | :: | no_header |
Avoid insert header to usage. |
|
logical, | intent(in), | optional | :: | markdown |
Format things form markdown. |
Usage string.
Get CLAsG signature.
Get CLAsG signature.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(in) | :: | self |
CLAsG data. |
||
logical, | intent(in), | optional | :: | bash_completion |
Return the signature for bash completion. |
|
logical, | intent(in), | optional | :: | plain |
Return the signature as plain switches list. |
Signature.
Sanitize default values.
Sanitize defaults values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(inout) | :: | self |
CLAsG data. |
Trig error occurrence and print meaningful message.
Trig error occurrence and print meaningful message.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(inout) | :: | self |
CLAsG data. |
||
integer(kind=I4P), | intent(in) | :: | error |
Error occurred. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
|
integer(kind=I4P), | intent(in), | optional | :: | a1 |
First index CLAs group inconsistent. |
|
integer(kind=I4P), | intent(in), | optional | :: | a2 |
Second index CLAs group inconsistent. |
Check if two mutually exclusive CLAs have been passed.
Check if two mutually exclusive CLAs have been passed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(inout) | :: | self |
CLAsG data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
Assignment operator.
Assignment operator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(inout) | :: | lhs |
Left hand side. |
||
type(command_line_arguments_group), | intent(in) | :: | rhs |
Right hand side. |
Assignment operator overloading.
Assignment operator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(inout) | :: | lhs |
Left hand side. |
||
type(command_line_arguments_group), | intent(in) | :: | rhs |
Right hand side. |
type, extends(object) :: command_line_arguments_group !< Command Line Arguments Group (CLAsG) class. !< !< CLAsG are useful for building nested commands. private character(len=:), allocatable, public :: group !< Group name (command). integer(I4P), public :: Na=0_I4P !< Number of CLA. integer(I4P) :: Na_required=0_I4P !< Number of required command line arguments. integer(I4P) :: Na_optional=0_I4P !< Number of optional command line arguments. type(command_line_argument), allocatable, public :: cla(:) !< CLA list [1:Na]. logical, public :: is_called=.false. !< Flag for checking if CLAs group has been passed to CLI. contains ! public methods procedure, public :: free !< Free dynamic memory. procedure, public :: check !< Check data consistency. procedure, public :: is_required_passed !< Check if required CLAs are passed. procedure, public :: is_passed !< Check if a CLA has been passed. procedure, public :: is_defined !< Check if a CLA has been defined. procedure, public :: raise_error_m_exclude !< Raise error mutually exclusive CLAs passed. procedure, public :: add !< Add CLA to CLAsG. procedure, public :: parse !< Parse CLAsG arguments. procedure, public :: usage !< Get correct CLAsG usage. procedure, public :: signature !< Get CLAsG signature. procedure, public :: sanitize_defaults !< Sanitize default values. ! private methods procedure, private :: errored !< Trig error occurrence and print meaningful message. procedure, private :: check_m_exclusive !< Check if two mutually exclusive CLAs have been passed. procedure, private :: clasg_assign_clasg !< Assignment operator. generic, private :: assignment(=) => clasg_assign_clasg !< Assignment operator overloading. final :: finalize !< Free dynamic memory when finalizing. endtype command_line_arguments_group