cli_add_flag Subroutine

private subroutine cli_add_flag(this, name, help, short)

Declare a flag, which takes no value.

An absent flag reads back as "false", a present one as "true", so get into a logical works without a special case.

Type Bound

cli_t

Arguments

Type IntentOptional Attributes Name
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.


Calls

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

Source Code

   subroutine cli_add_flag(this, name, help, short)
      !! Declare a flag, which takes no value.
      !!
      !! An absent flag reads back as `"false"`, a present one as `"true"`, so
      !! `get` into a `logical` works without a special case.
      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.

      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_FLAG
      this%entries(this%count)%required = .false.
      this%entries(this%count)%seen = 0_default_int
      this%entries(this%count)%value = "false"
      this%entries(this%count)%default = "false"
      if (present(short)) then
         this%entries(this%count)%short = short
      else
         this%entries(this%count)%short = ""
      end if
   end subroutine cli_add_flag