cli_add_positional Subroutine

private subroutine cli_add_positional(this, name, help, required, default)

Declare a positional argument, filled in registration order.

Type Bound

cli_t

Arguments

Type IntentOptional Attributes Name
class(cli_t), intent(inout) :: this
character(len=*), intent(in) :: name

Name used to read the value back, and in the usage line.

character(len=*), intent(in) :: help

One-line description.

logical, intent(in), optional :: required

Whether a parse without it is ERROR_VALIDATION; default false.

character(len=*), intent(in), optional :: default

Value get returns when the argument is absent.


Calls

proc~~cli_add_positional~~CallsGraph proc~cli_add_positional cli_t%cli_add_positional proc~cli_reserve cli_t%cli_reserve proc~cli_add_positional->proc~cli_reserve

Source Code

   subroutine cli_add_positional(this, name, help, required, default)
      !! Declare a positional argument, filled in registration order.
      class(cli_t), intent(inout) :: this
      character(len=*), intent(in) :: name
         !! Name used to read the value back, and in the usage line.
      character(len=*), intent(in) :: help
         !! One-line description.
      logical, intent(in), optional :: required
         !! Whether a parse without it is `ERROR_VALIDATION`; default false.
      character(len=*), intent(in), optional :: default
         !! Value `get` returns when the argument is absent.

      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)%short = ""
      this%entries(this%count)%kind = KIND_POSITIONAL
      this%entries(this%count)%seen = 0_default_int
      if (present(required)) then
         this%entries(this%count)%required = required
      else
         this%entries(this%count)%required = .false.
      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_positional