Add CLA to CLAs list.
Note
If not otherwise declared the action on CLA value is set to “store” a value that must be passed after the switch name or directly passed in case of positional CLA.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(inout) | :: | self |
CLAsG data. |
||
character(len=*), | intent(in), | optional | :: | pref |
Prefixing string. |
|
type(command_line_argument), | intent(in) | :: | cla |
CLA data. |
subroutine add(self, pref, cla) !< Add CLA to CLAs list. !< !< @note If not otherwise declared the action on CLA value is set to "store" a value that must be passed after the switch name !< or directly passed in case of positional CLA. class(command_line_arguments_group), intent(inout) :: self !< CLAsG data. character(*), optional, intent(in) :: pref !< Prefixing string. type(command_line_argument), intent(in) :: cla !< CLA data. type(command_line_argument), allocatable :: cla_list_new(:) !< New (extended) CLA list. integer(I4P) :: c !< Counter. if (self%Na>0_I4P) then if (.not.cla%is_positional) then allocate(cla_list_new(1:self%Na+1)) do c=1, self%Na cla_list_new(c) = self%cla(c) enddo cla_list_new(self%Na+1) = cla else allocate(cla_list_new(1:self%Na+1)) do c=1, cla%position - 1 cla_list_new(c) = self%cla(c) enddo cla_list_new(cla%position) = cla do c=cla%position + 1, self%Na + 1 cla_list_new(c) = self%cla(c-1) enddo endif else allocate(cla_list_new(1:1)) cla_list_new(1)=cla endif call move_alloc(from=cla_list_new, to=self%cla) self%Na = self%Na + 1 if (cla%is_required) then self%Na_required = self%Na_required + 1 else self%Na_optional = self%Na_optional + 1 endif if (allocated(cla_list_new)) deallocate(cla_list_new) call self%check(pref=pref) endsubroutine add