get_cla Subroutine

private subroutine get_cla(self, val, pref, args, group, switch, position, error)

Get CLA (single) value from CLAs list parsed.

Note

For logical type CLA the value is directly read without any robust error trapping.

Type Bound

command_line_interface

Arguments

Type IntentOptional Attributes Name
class(command_line_interface), intent(inout) :: self

CLI data.

class(*), intent(inout) :: val

CLA value.

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

Prefixing string.

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

String containing command line arguments.

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

Name of group (command) of CLA.

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

Switch name.

integer(kind=I4P), intent(in), optional :: position

Position of positional CLA.

integer(kind=I4P), intent(out), optional :: error

Error trapping flag.


Calls

proc~~get_cla~2~~CallsGraph proc~get_cla~2 flap_command_line_interface_t::command_line_interface%get_cla none~get flap_command_line_argument_t::command_line_argument%get proc~get_cla~2->none~get proc~errored~3 flap_command_line_interface_t::command_line_interface%errored proc~get_cla~2->proc~errored~3 proc~is_defined_group flap_command_line_interface_t::command_line_interface%is_defined_group proc~get_cla~2->proc~is_defined_group proc~parse~2 flap_command_line_interface_t::command_line_interface%parse proc~get_cla~2->proc~parse~2 proc~get_cla flap_command_line_argument_t::command_line_argument%get_cla none~get->proc~get_cla proc~get_cla_list flap_command_line_argument_t::command_line_argument%get_cla_list none~get->proc~get_cla_list interface~colorize face::colorize proc~errored~3->interface~colorize proc~print_error_message flap_object_t::object%print_error_message proc~errored~3->proc~print_error_message none~get_args flap_command_line_interface_t::command_line_interface%get_args proc~parse~2->none~get_args proc~add~2 flap_command_line_interface_t::command_line_interface%add proc~parse~2->proc~add~2 proc~check_m_exclusive~2 flap_command_line_interface_t::command_line_interface%check_m_exclusive proc~parse~2->proc~check_m_exclusive~2 proc~check~3 flap_command_line_interface_t::command_line_interface%check proc~parse~2->proc~check~3 proc~is_defined~2 flap_command_line_interface_t::command_line_interface%is_defined proc~parse~2->proc~is_defined~2 proc~is_required_passed flap_command_line_arguments_group_t::command_line_arguments_group%is_required_passed proc~parse~2->proc~is_required_passed proc~parse flap_command_line_arguments_group_t::command_line_arguments_group%parse proc~parse~2->proc~parse proc~print_version flap_object_t::object%print_version proc~parse~2->proc~print_version proc~sanitize_defaults flap_command_line_arguments_group_t::command_line_arguments_group%sanitize_defaults proc~parse~2->proc~sanitize_defaults proc~save_usage_to_markdown flap_command_line_interface_t::command_line_interface%save_usage_to_markdown proc~parse~2->proc~save_usage_to_markdown proc~usage~3 flap_command_line_interface_t::command_line_interface%usage proc~parse~2->proc~usage~3 proc~colorize_default face::colorize_default interface~colorize->proc~colorize_default proc~get_args_from_invocation flap_command_line_interface_t::command_line_interface%get_args_from_invocation none~get_args->proc~get_args_from_invocation proc~get_args_from_string flap_command_line_interface_t::command_line_interface%get_args_from_string none~get_args->proc~get_args_from_string proc~add~2->proc~is_defined_group proc~add flap_command_line_arguments_group_t::command_line_arguments_group%add proc~add~2->proc~add proc~add_group flap_command_line_interface_t::command_line_interface%add_group proc~add~2->proc~add_group proc~assign_object flap_object_t::object%assign_object proc~add~2->proc~assign_object proc~check~2 flap_command_line_argument_t::command_line_argument%check proc~add~2->proc~check~2 proc~upper_case flap_utils_m::upper_case proc~add~2->proc~upper_case proc~check_m_exclusive~2->proc~is_defined_group proc~raise_error_m_exclude flap_command_line_arguments_group_t::command_line_arguments_group%raise_error_m_exclude proc~check_m_exclusive~2->proc~raise_error_m_exclude proc~check~3->proc~is_defined_group proc~check flap_command_line_arguments_group_t::command_line_arguments_group%check proc~check~3->proc~check proc~check_choices flap_command_line_argument_t::command_line_argument%check_choices proc~get_cla->proc~check_choices proc~errored~2 flap_command_line_argument_t::command_line_argument%errored proc~get_cla->proc~errored~2 proc~get_cla_from_buffer flap_command_line_argument_t::command_line_argument%get_cla_from_buffer proc~get_cla->proc~get_cla_from_buffer proc~is_required_passed~2 flap_command_line_argument_t::command_line_argument%is_required_passed proc~get_cla->proc~is_required_passed~2 proc~get_cla_list->proc~errored~2 proc~get_cla_list_from_buffer flap_command_line_argument_t::command_line_argument%get_cla_list_from_buffer proc~get_cla_list->proc~get_cla_list_from_buffer proc~get_cla_list->proc~is_required_passed~2 proc~tokenize flap_utils_m::tokenize proc~get_cla_list->proc~tokenize proc~is_defined~2->proc~is_defined_group proc~is_defined flap_command_line_arguments_group_t::command_line_arguments_group%is_defined proc~is_defined~2->proc~is_defined proc~is_required_passed->proc~is_required_passed~2 proc~usage flap_command_line_arguments_group_t::command_line_arguments_group%usage proc~is_required_passed->proc~usage proc~parse->proc~sanitize_defaults cton cton proc~parse->cton proc~parse->proc~add proc~parse->proc~assign_object proc~check_m_exclusive flap_command_line_arguments_group_t::command_line_arguments_group%check_m_exclusive proc~parse->proc~check_m_exclusive proc~parse->proc~is_defined proc~raise_error_duplicated_clas flap_command_line_argument_t::command_line_argument%raise_error_duplicated_clas proc~parse->proc~raise_error_duplicated_clas proc~raise_error_nargs_insufficient flap_command_line_argument_t::command_line_argument%raise_error_nargs_insufficient proc~parse->proc~raise_error_nargs_insufficient proc~raise_error_switch_unknown flap_command_line_argument_t::command_line_argument%raise_error_switch_unknown proc~parse->proc~raise_error_switch_unknown proc~raise_error_value_missing flap_command_line_argument_t::command_line_argument%raise_error_value_missing proc~parse->proc~raise_error_value_missing proc~sanitize_defaults~2 flap_command_line_argument_t::command_line_argument%sanitize_defaults proc~sanitize_defaults->proc~sanitize_defaults~2 proc~save_usage_to_markdown->proc~usage~3 proc~signature~3 flap_command_line_interface_t::command_line_interface%signature proc~save_usage_to_markdown->proc~signature~3 strz strz proc~save_usage_to_markdown->strz proc~usage~3->proc~signature~3 proc~usage~3->proc~usage proc~add->proc~check proc~add_group->proc~is_defined_group proc~add_group->proc~assign_object proc~set_examples flap_object_t::object%set_examples proc~add_group->proc~set_examples proc~check->proc~is_defined proc~errored flap_command_line_arguments_group_t::command_line_arguments_group%errored proc~check->proc~errored proc~check_choices->cton proc~check_choices->proc~errored~2 proc~check_choices->proc~tokenize str str proc~check_choices->str proc~is_passed flap_command_line_arguments_group_t::command_line_arguments_group%is_passed proc~check_m_exclusive->proc~is_passed proc~raise_error_m_exclude~2 flap_command_line_argument_t::command_line_argument%raise_error_m_exclude proc~check_m_exclusive->proc~raise_error_m_exclude~2 proc~check_action_consistency flap_command_line_argument_t::command_line_argument%check_action_consistency proc~check~2->proc~check_action_consistency proc~check_envvar_consistency flap_command_line_argument_t::command_line_argument%check_envvar_consistency proc~check~2->proc~check_envvar_consistency proc~check_m_exclude_consistency flap_command_line_argument_t::command_line_argument%check_m_exclude_consistency proc~check~2->proc~check_m_exclude_consistency proc~check_named_consistency flap_command_line_argument_t::command_line_argument%check_named_consistency proc~check~2->proc~check_named_consistency proc~check_optional_consistency flap_command_line_argument_t::command_line_argument%check_optional_consistency proc~check~2->proc~check_optional_consistency proc~check_positional_consistency flap_command_line_argument_t::command_line_argument%check_positional_consistency proc~check~2->proc~check_positional_consistency proc~color_index face::color_index proc~colorize_default->proc~color_index proc~style_index face::style_index proc~colorize_default->proc~style_index proc~upper face::upper proc~colorize_default->proc~upper proc~errored~2->interface~colorize proc~errored~2->proc~print_error_message proc~errored~2->str proc~get_clasg_indexes flap_command_line_interface_t::command_line_interface%get_clasg_indexes proc~get_args_from_invocation->proc~get_clasg_indexes proc~get_args_from_string->proc~tokenize proc~get_args_from_string->proc~get_clasg_indexes proc~get_cla_from_buffer->cton proc~get_cla_from_buffer->proc~errored~2 proc~get_cla_list_from_buffer->cton proc~get_cla_list_from_buffer->proc~check_choices proc~get_cla_list_from_buffer->proc~errored~2 proc~get_cla_list_from_buffer->proc~tokenize proc~is_required_passed~2->proc~errored~2 proc~raise_error_duplicated_clas->proc~errored~2 proc~raise_error_m_exclude->proc~errored proc~raise_error_nargs_insufficient->proc~errored~2 proc~raise_error_switch_unknown->proc~errored~2 proc~raise_error_value_missing->proc~errored~2 proc~replace_all flap_utils_m::replace_all proc~sanitize_defaults~2->proc~replace_all proc~unique flap_utils_m::unique proc~sanitize_defaults~2->proc~unique proc~wstrip flap_utils_m::wstrip proc~sanitize_defaults~2->proc~wstrip proc~signature flap_command_line_arguments_group_t::command_line_arguments_group%signature proc~signature~3->proc~signature proc~usage->proc~signature proc~usage~2 flap_command_line_argument_t::command_line_argument%usage proc~usage->proc~usage~2 proc~check_action_consistency->proc~errored~2 proc~check_envvar_consistency->proc~errored~2 proc~check_m_exclude_consistency->proc~errored~2 proc~check_named_consistency->proc~errored~2 proc~check_optional_consistency->proc~errored~2 proc~check_positional_consistency->proc~errored~2 proc~errored->interface~colorize proc~errored->proc~print_error_message proc~errored->str proc~get_clasg_indexes->proc~is_defined_group proc~raise_error_m_exclude~2->proc~errored~2 proc~replace_all->proc~wstrip proc~replace flap_utils_m::replace proc~replace_all->proc~replace proc~signature~2 flap_command_line_argument_t::command_line_argument%signature proc~signature->proc~signature~2 proc~usage~2->interface~colorize proc~usage~2->cton proc~usage~2->proc~replace_all proc~usage~2->str proc~signature~2->cton proc~signature~2->str proc~has_choices flap_command_line_argument_t::command_line_argument%has_choices proc~signature~2->proc~has_choices

Called by

proc~~get_cla~2~~CalledByGraph proc~get_cla~2 flap_command_line_interface_t::command_line_interface%get_cla none~get~2 flap_command_line_interface_t::command_line_interface%get none~get~2->proc~get_cla~2 proc~fake_call flap_test_group::fake_call proc~fake_call->none~get~2 program~flap_save_man_page flap_save_man_page program~flap_save_man_page->none~get~2 program~flap_save_usage_to_markdown flap_save_usage_to_markdown program~flap_save_usage_to_markdown->none~get~2 program~flap_test_action_store flap_test_action_store program~flap_test_action_store->none~get~2 program~flap_test_ansi_color_style flap_test_ansi_color_style program~flap_test_ansi_color_style->none~get~2 program~flap_test_basic flap_test_basic program~flap_test_basic->none~get~2 program~flap_test_choices_logical flap_test_choices_logical program~flap_test_choices_logical->none~get~2 program~flap_test_duplicated_clas flap_test_duplicated_clas program~flap_test_duplicated_clas->none~get~2 program~flap_test_group_examples flap_test_group_examples program~flap_test_group_examples->none~get~2 program~flap_test_hidden flap_test_hidden program~flap_test_hidden->none~get~2 program~flap_test_ignore_unknown_clas flap_test_ignore_unknown_clas program~flap_test_ignore_unknown_clas->none~get~2 program~flap_test_minimal flap_test_minimal program~flap_test_minimal->none~get~2 program~flap_test_nargs_insufficient flap_test_nargs_insufficient program~flap_test_nargs_insufficient->none~get~2 program~flap_test_nargs_insufficient~2 flap_test_nargs_insufficient program~flap_test_nargs_insufficient~2->none~get~2 program~flap_test_nested flap_test_nested program~flap_test_nested->none~get~2 program~flap_test_string flap_test_string program~flap_test_string->none~get~2 program~flap_test_group flap_test_group program~flap_test_group->proc~fake_call

Source Code

  subroutine get_cla(self, val, pref, args, group, switch, position, error)
  !< Get CLA (single) value from CLAs list parsed.
  !<
  !< @note For logical type CLA the value is directly read without any robust error trapping.
  class(command_line_interface), intent(inout) :: self     !< CLI data.
  class(*),                      intent(inout) :: val      !< CLA value.
  character(*), optional,        intent(in)    :: pref     !< Prefixing string.
  character(*), optional,        intent(in)    :: args     !< String containing command line arguments.
  character(*), optional,        intent(in)    :: group    !< Name of group (command) of CLA.
  character(*), optional,        intent(in)    :: switch   !< Switch name.
  integer(I4P), optional,        intent(in)    :: position !< Position of positional CLA.
  integer(I4P), optional,        intent(out)   :: error    !< Error trapping flag.
  logical                                      :: found    !< Flag for checking if CLA containing switch has been found.
  integer(I4P)                                 :: g        !< Group counter.
  integer(I4P)                                 :: a        !< Argument counter.

  if (.not.self%is_parsed_) then
    call self%parse(pref=pref, args=args, error=error)
    if (self%error>0.and.self%error_unknown_clas/=ERROR_UNKNOWN_CLAS_IGNORED) return
  endif
  if (present(group)) then
    if (.not.self%is_defined_group(group=group, g=g)) then
      call self%errored(pref=pref, error=ERROR_MISSING_GROUP, group=group)
    endif
  else
    g = 0
  endif
  if (self%error==0.or.self%error_unknown_clas==ERROR_UNKNOWN_CLAS_IGNORED) then
    if (present(switch)) then
      ! search for the CLA corresponding to switch
      found = .false.
      do a=1,self%clasg(g)%Na
        if (.not.self%clasg(g)%cla(a)%is_positional) then
          if ((self%clasg(g)%cla(a)%switch==switch).or.(self%clasg(g)%cla(a)%switch_ab==switch)) then
            found = .true.
            exit
          endif
        endif
      enddo
      if (.not.found) then
        call self%errored(pref=pref, error=ERROR_MISSING_CLA, switch=switch)
      else
        call self%clasg(g)%cla(a)%get(pref=pref, val=val) ; self%error = self%clasg(g)%cla(a)%error
      endif
    elseif (present(position)) then
      call self%clasg(g)%cla(position)%get(pref=pref, val=val) ; self%error = self%clasg(g)%cla(position)%error
    else
      call self%errored(pref=pref, error=ERROR_MISSING_SELECTION_CLA)
    endif
  endif
  ! check if the only error found is for unknown passed CLAs and if it is ignored by the user
  if (self%error==ERROR_UNKNOWN.and.self%error_unknown_clas==ERROR_UNKNOWN_CLAS_IGNORED) self%error = ERROR_UNKNOWN_CLAS_IGNORED
  if (self%error==0.and.(.not.self%clasg(g)%is_called)) then
    ! TODO warn (if liked) for non invoked group querying
  endif
  if (present(error)) error = self%error
  endsubroutine get_cla