Get CLAs from CLI invocation.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_interface), | intent(inout) | :: | self |
CLI data. |
||
integer(kind=I4P), | intent(out), | allocatable | :: | ai(:,:) |
CLAs grouped indexes. |
subroutine get_args_from_invocation(self, ai) !< Get CLAs from CLI invocation. class(command_line_interface), intent(inout) :: self !< CLI data. integer(I4P), allocatable, intent(out) :: ai(:,:) !< CLAs grouped indexes. integer(I4P) :: Na !< Number of command line arguments passed. character(max_val_len) :: switch !< Switch name. integer(I4P) :: a !< Counter for CLAs. integer(I4P) :: aa !< Counter for CLAs. if (allocated(self%args)) deallocate(self%args) Na = command_argument_count() if (Na > 0) then #ifdef __GFORTRAN__ allocate(self%args(1:Na)) #else aa = 0 find_longest_arg: do a=1, Na call get_command_argument(a,switch) aa = max(aa,len_trim(switch)) enddo find_longest_arg allocate(character(aa):: self%args(1:Na)) #endif get_args: do a=1, Na call get_command_argument(a,switch) self%args(a) = trim(adjustl(switch)) enddo get_args endif call self%get_clasg_indexes(ai=ai) endsubroutine get_args_from_invocation