Declare an option that takes a value.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(cli_t), | intent(inout) | :: | this | |||
| character(len=*), | intent(in) | :: | name |
Long name, given on the command line as |
||
| character(len=*), | intent(in) | :: | help |
One-line description. |
||
| character(len=*), | intent(in), | optional | :: | short |
Single-character short name, given as |
|
| character(len=*), | intent(in), | optional | :: | default |
Value |
subroutine cli_add_option(this, name, help, short, default) !! Declare an option that takes a value. class(cli_t), intent(inout) :: this character(len=*), intent(in) :: name !! Long name, given on the command line as `--name`. character(len=*), intent(in) :: help !! One-line description. character(len=*), intent(in), optional :: short !! Single-character short name, given as `-s`. character(len=*), intent(in), optional :: default !! Value `get` returns when the option is absent; empty if omitted. call this%reserve() this%count = this%count + 1_default_int this%entries(this%count)%name = name this%entries(this%count)%help = help this%entries(this%count)%kind = KIND_OPTION this%entries(this%count)%required = .false. this%entries(this%count)%seen = 0_default_int if (present(short)) then this%entries(this%count)%short = short else this%entries(this%count)%short = "" end if if (present(default)) then this%entries(this%count)%value = default this%entries(this%count)%default = default else this%entries(this%count)%value = "" this%entries(this%count)%default = "" end if end subroutine cli_add_option