Get CLAsG signature.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_arguments_group), | intent(in) | :: | self |
CLAsG data. |
||
logical, | intent(in), | optional | :: | bash_completion |
Return the signature for bash completion. |
|
logical, | intent(in), | optional | :: | plain |
Return the signature as plain switches list. |
Signature.
function signature(self, bash_completion, plain) !< Get CLAsG signature. class(command_line_arguments_group), intent(in) :: self !< CLAsG data. logical, optional, intent(in) :: bash_completion !< Return the signature for bash completion. logical, optional, intent(in) :: plain !< Return the signature as plain switches list. ! logical :: plain_ !< Return the signature as plain switches list, local var. logical :: bash_completion_ !< Return the signature for bash completion, local variable. character(len=:), allocatable :: signature !< Signature. ! logical :: clas_choices !< Flag to check if there are CLAs with choices. integer(I4P) :: a!, aa !< Counter. signature = '' bash_completion_ = .false. ; if (present(bash_completion)) bash_completion_ = bash_completion ! plain_ = .false. ; if (present(plain)) plain_ = plain ! if (bash_completion_) then ! ! if (plain_) then ! ! do a=1, self%Na ! ! signature = signature//self%cla(a)%signature(bash_completion=bash_completion, plain=plain) ! ! enddo ! ! else ! clas_choices = .false. ! do a=1, self%Na ! if (self%cla(a)%has_choices()) then ! aa = a ! clas_choices = .true. ! exit ! endif ! enddo ! if (clas_choices) then ! signature = signature//new_line('a')//& ! ' if [ "$prev" == "'//self%cla(aa)%switch//'" ] || [ "$prev" == "'//self%cla(aa)%switch_ab//'" ] ; then' ! signature = signature//new_line('a')//' COMPREPLY=( $( compgen -W "'//choices(self%cla(aa)%choices)//'" -- $cur ) )' ! do a=aa+1, self%Na ! if (self%cla(a)%has_choices()) then ! signature = signature//new_line('a')//& ! ' elif [ "$prev" == "'//self%cla(a)%switch//'" ] || [ "$prev" == "'//self%cla(a)%switch_ab//'" ] ; then' ! signature = signature//new_line('a')//' COMPREPLY=( $( compgen -W "'//choices(self%cla(a)%choices)//& ! '" -- $cur ) )' ! endif ! enddo ! signature = signature//new_line('a')//' else'//new_line('a')//' COMPREPLY=( $( compgen -W "' ! do a=1, self%Na ! signature = signature//self%cla(a)%signature(bash_completion=bash_completion) ! enddo ! signature = signature//'" -- $cur ) )'//new_line('a')//' fi' ! else ! signature = signature//new_line('a')//' COMPREPLY=( $( compgen -W "' ! do a=1, self%Na ! signature = signature//self%cla(a)%signature(bash_completion=bash_completion) ! enddo ! signature = signature//'" -- $cur ) )' ! endif ! ! endif ! else if (bash_completion_) then do a=1, self%Na signature = signature//self%cla(a)%signature(bash_completion=bash_completion, plain=.true.) enddo signature = new_line('a')//' COMPREPLY=( $( compgen -W "'//signature//'" -- $cur ) )' endif do a=1, self%Na signature = signature//self%cla(a)%signature(bash_completion=bash_completion, plain=plain) enddo ! endif !contains ! pure function choices(choices_c) ! !< Return space-separated choices list from a comma-separated one. ! character(len=*), intent(in) :: choices_c !< Comma-separated list of choices. ! character(len=len(choices_c)) :: choices !< Space-separated list of choices. ! integer(I4P) :: c !< Counter. ! choices = choices_c ! do c=1, len(choices) ! if (choices(c:c)==',') choices(c:c) = ' ' ! enddo ! endfunction choices endfunction signature