github.com/openshift/source-to-image@v1.4.1-0.20240516041539-bf52fc02204e/contrib/completions/zsh/s2i (about)

     1  # Copyright 2016 The Kubernetes Authors.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #     http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  
    15  __kubectl_bash_source() {
    16  	alias shopt=':'
    17  	alias _expand=_bash_expand
    18  	alias _complete=_bash_comp
    19  	emulate -L sh
    20  	setopt kshglob noshglob braceexpand
    21  
    22  	source "$@"
    23  }
    24  
    25  __kubectl_type() {
    26  	# -t is not supported by zsh
    27  	if [ "$1" == "-t" ]; then
    28  		shift
    29  
    30  		# fake Bash 4 to disable "complete -o nospace". Instead
    31  		# "compopt +-o nospace" is used in the code to toggle trailing
    32  		# spaces. We don't support that, but leave trailing spaces on
    33  		# all the time
    34  		if [ "$1" = "__kubectl_compopt" ]; then
    35  			echo builtin
    36  			return 0
    37  		fi
    38  	fi
    39  	type "$@"
    40  }
    41  
    42  __kubectl_compgen() {
    43  	local completions w
    44  	completions=( $(compgen "$@") ) || return $?
    45  
    46  	# filter by given word as prefix
    47  	while [[ "$1" = -* && "$1" != -- ]]; do
    48  		shift
    49  		shift
    50  	done
    51  	if [[ "$1" == -- ]]; then
    52  		shift
    53  	fi
    54  	for w in "${completions[@]}"; do
    55  		if [[ "${w}" = "$1"* ]]; then
    56  			echo "${w}"
    57  		fi
    58  	done
    59  }
    60  
    61  __kubectl_compopt() {
    62  	true # don't do anything. Not supported by bashcompinit in zsh
    63  }
    64  
    65  __kubectl_declare() {
    66  	if [ "$1" == "-F" ]; then
    67  		whence -w "$@"
    68  	else
    69  		builtin declare "$@"
    70  	fi
    71  }
    72  
    73  __kubectl_ltrim_colon_completions()
    74  {
    75  	if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then
    76  		# Remove colon-word prefix from COMPREPLY items
    77  		local colon_word=${1%${1##*:}}
    78  		local i=${#COMPREPLY[*]}
    79  		while [[ $((--i)) -ge 0 ]]; do
    80  			COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}
    81  		done
    82  	fi
    83  }
    84  
    85  __kubectl_get_comp_words_by_ref() {
    86  	cur="${COMP_WORDS[COMP_CWORD]}"
    87  	prev="${COMP_WORDS[${COMP_CWORD}-1]}"
    88  	words=("${COMP_WORDS[@]}")
    89  	cword=("${COMP_CWORD[@]}")
    90  }
    91  
    92  __kubectl_filedir() {
    93  	local RET OLD_IFS w qw
    94  
    95  	__debug "_filedir $@ cur=$cur"
    96  	if [[ "$1" = \~* ]]; then
    97  		# somehow does not work. Maybe, zsh does not call this at all
    98  		eval echo "$1"
    99  		return 0
   100  	fi
   101  
   102  	OLD_IFS="$IFS"
   103  	IFS=$'\n'
   104  	if [ "$1" = "-d" ]; then
   105  		shift
   106  		RET=( $(compgen -d) )
   107  	else
   108  		RET=( $(compgen -f) )
   109  	fi
   110  	IFS="$OLD_IFS"
   111  
   112  	IFS="," __debug "RET=${RET[@]} len=${#RET[@]}"
   113  
   114  	for w in ${RET[@]}; do
   115  		if [[ ! "${w}" = "${cur}"* ]]; then
   116  			continue
   117  		fi
   118  		if eval "[[ \"\${w}\" = *.$1 || -d \"\${w}\" ]]"; then
   119  			qw="$(__kubectl_quote "${w}")"
   120  			if [ -d "${w}" ]; then
   121  				COMPREPLY+=("${qw}/")
   122  			else
   123  				COMPREPLY+=("${qw}")
   124  			fi
   125  		fi
   126  	done
   127  }
   128  
   129  __kubectl_quote() {
   130      if [[ $1 == \'* || $1 == \"* ]]; then
   131          # Leave out first character
   132          printf %q "${1:1}"
   133      else
   134      	printf %q "$1"
   135      fi
   136  }
   137  
   138  autoload -U +X bashcompinit && bashcompinit
   139  
   140  # use word boundary patterns for BSD or GNU sed
   141  LWORD='[[:<:]]'
   142  RWORD='[[:>:]]'
   143  if sed --help 2>&1 | grep -q GNU; then
   144  	LWORD='\<'
   145  	RWORD='\>'
   146  fi
   147  
   148  __kubectl_convert_bash_to_zsh() {
   149  	sed \
   150  	-e 's/declare -F/whence -w/' \
   151  	-e 's/local \([a-zA-Z0-9_]*\)=/local \1; \1=/' \
   152  	-e 's/flags+=("\(--.*\)=")/flags+=("\1"); two_word_flags+=("\1")/' \
   153  	-e 's/must_have_one_flag+=("\(--.*\)=")/must_have_one_flag+=("\1")/' \
   154  	-e "s/${LWORD}_filedir${RWORD}/__kubectl_filedir/g" \
   155  	-e "s/${LWORD}_get_comp_words_by_ref${RWORD}/__kubectl_get_comp_words_by_ref/g" \
   156  	-e "s/${LWORD}__ltrim_colon_completions${RWORD}/__kubectl_ltrim_colon_completions/g" \
   157  	-e "s/${LWORD}compgen${RWORD}/__kubectl_compgen/g" \
   158  	-e "s/${LWORD}compopt${RWORD}/__kubectl_compopt/g" \
   159  	-e "s/${LWORD}declare${RWORD}/__kubectl_declare/g" \
   160  	-e "s/\\\$(type${RWORD}/\$(__kubectl_type/g" \
   161  	<<'BASH_COMPLETION_EOF'
   162  # bash completion for s2i                                  -*- shell-script -*-
   163  
   164  __s2i_debug()
   165  {
   166      if [[ -n ${BASH_COMP_DEBUG_FILE:-} ]]; then
   167          echo "$*" >> "${BASH_COMP_DEBUG_FILE}"
   168      fi
   169  }
   170  
   171  # Homebrew on Macs have version 1.3 of bash-completion which doesn't include
   172  # _init_completion. This is a very minimal version of that function.
   173  __s2i_init_completion()
   174  {
   175      COMPREPLY=()
   176      _get_comp_words_by_ref "$@" cur prev words cword
   177  }
   178  
   179  __s2i_index_of_word()
   180  {
   181      local w word=$1
   182      shift
   183      index=0
   184      for w in "$@"; do
   185          [[ $w = "$word" ]] && return
   186          index=$((index+1))
   187      done
   188      index=-1
   189  }
   190  
   191  __s2i_contains_word()
   192  {
   193      local w word=$1; shift
   194      for w in "$@"; do
   195          [[ $w = "$word" ]] && return
   196      done
   197      return 1
   198  }
   199  
   200  __s2i_handle_go_custom_completion()
   201  {
   202      __s2i_debug "${FUNCNAME[0]}: cur is ${cur}, words[*] is ${words[*]}, #words[@] is ${#words[@]}"
   203  
   204      local shellCompDirectiveError=1
   205      local shellCompDirectiveNoSpace=2
   206      local shellCompDirectiveNoFileComp=4
   207      local shellCompDirectiveFilterFileExt=8
   208      local shellCompDirectiveFilterDirs=16
   209  
   210      local out requestComp lastParam lastChar comp directive args
   211  
   212      # Prepare the command to request completions for the program.
   213      # Calling ${words[0]} instead of directly s2i allows handling aliases
   214      args=("${words[@]:1}")
   215      # Disable ActiveHelp which is not supported for bash completion v1
   216      requestComp="S2I_ACTIVE_HELP=0 ${words[0]} __completeNoDesc ${args[*]}"
   217  
   218      lastParam=${words[$((${#words[@]}-1))]}
   219      lastChar=${lastParam:$((${#lastParam}-1)):1}
   220      __s2i_debug "${FUNCNAME[0]}: lastParam ${lastParam}, lastChar ${lastChar}"
   221  
   222      if [ -z "${cur}" ] && [ "${lastChar}" != "=" ]; then
   223          # If the last parameter is complete (there is a space following it)
   224          # We add an extra empty parameter so we can indicate this to the go method.
   225          __s2i_debug "${FUNCNAME[0]}: Adding extra empty parameter"
   226          requestComp="${requestComp} \"\""
   227      fi
   228  
   229      __s2i_debug "${FUNCNAME[0]}: calling ${requestComp}"
   230      # Use eval to handle any environment variables and such
   231      out=$(eval "${requestComp}" 2>/dev/null)
   232  
   233      # Extract the directive integer at the very end of the output following a colon (:)
   234      directive=${out##*:}
   235      # Remove the directive
   236      out=${out%:*}
   237      if [ "${directive}" = "${out}" ]; then
   238          # There is not directive specified
   239          directive=0
   240      fi
   241      __s2i_debug "${FUNCNAME[0]}: the completion directive is: ${directive}"
   242      __s2i_debug "${FUNCNAME[0]}: the completions are: ${out}"
   243  
   244      if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
   245          # Error code.  No completion.
   246          __s2i_debug "${FUNCNAME[0]}: received error from custom completion go code"
   247          return
   248      else
   249          if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
   250              if [[ $(type -t compopt) = "builtin" ]]; then
   251                  __s2i_debug "${FUNCNAME[0]}: activating no space"
   252                  compopt -o nospace
   253              fi
   254          fi
   255          if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
   256              if [[ $(type -t compopt) = "builtin" ]]; then
   257                  __s2i_debug "${FUNCNAME[0]}: activating no file completion"
   258                  compopt +o default
   259              fi
   260          fi
   261      fi
   262  
   263      if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
   264          # File extension filtering
   265          local fullFilter filter filteringCmd
   266          # Do not use quotes around the $out variable or else newline
   267          # characters will be kept.
   268          for filter in ${out}; do
   269              fullFilter+="$filter|"
   270          done
   271  
   272          filteringCmd="_filedir $fullFilter"
   273          __s2i_debug "File filtering command: $filteringCmd"
   274          $filteringCmd
   275      elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
   276          # File completion for directories only
   277          local subdir
   278          # Use printf to strip any trailing newline
   279          subdir=$(printf "%s" "${out}")
   280          if [ -n "$subdir" ]; then
   281              __s2i_debug "Listing directories in $subdir"
   282              __s2i_handle_subdirs_in_dir_flag "$subdir"
   283          else
   284              __s2i_debug "Listing directories in ."
   285              _filedir -d
   286          fi
   287      else
   288          while IFS='' read -r comp; do
   289              COMPREPLY+=("$comp")
   290          done < <(compgen -W "${out}" -- "$cur")
   291      fi
   292  }
   293  
   294  __s2i_handle_reply()
   295  {
   296      __s2i_debug "${FUNCNAME[0]}"
   297      local comp
   298      case $cur in
   299          -*)
   300              if [[ $(type -t compopt) = "builtin" ]]; then
   301                  compopt -o nospace
   302              fi
   303              local allflags
   304              if [ ${#must_have_one_flag[@]} -ne 0 ]; then
   305                  allflags=("${must_have_one_flag[@]}")
   306              else
   307                  allflags=("${flags[*]} ${two_word_flags[*]}")
   308              fi
   309              while IFS='' read -r comp; do
   310                  COMPREPLY+=("$comp")
   311              done < <(compgen -W "${allflags[*]}" -- "$cur")
   312              if [[ $(type -t compopt) = "builtin" ]]; then
   313                  [[ "${COMPREPLY[0]}" == *= ]] || compopt +o nospace
   314              fi
   315  
   316              # complete after --flag=abc
   317              if [[ $cur == *=* ]]; then
   318                  if [[ $(type -t compopt) = "builtin" ]]; then
   319                      compopt +o nospace
   320                  fi
   321  
   322                  local index flag
   323                  flag="${cur%=*}"
   324                  __s2i_index_of_word "${flag}" "${flags_with_completion[@]}"
   325                  COMPREPLY=()
   326                  if [[ ${index} -ge 0 ]]; then
   327                      PREFIX=""
   328                      cur="${cur#*=}"
   329                      ${flags_completion[${index}]}
   330                      if [ -n "${ZSH_VERSION:-}" ]; then
   331                          # zsh completion needs --flag= prefix
   332                          eval "COMPREPLY=( \"\${COMPREPLY[@]/#/${flag}=}\" )"
   333                      fi
   334                  fi
   335              fi
   336  
   337              if [[ -z "${flag_parsing_disabled}" ]]; then
   338                  # If flag parsing is enabled, we have completed the flags and can return.
   339                  # If flag parsing is disabled, we may not know all (or any) of the flags, so we fallthrough
   340                  # to possibly call handle_go_custom_completion.
   341                  return 0;
   342              fi
   343              ;;
   344      esac
   345  
   346      # check if we are handling a flag with special work handling
   347      local index
   348      __s2i_index_of_word "${prev}" "${flags_with_completion[@]}"
   349      if [[ ${index} -ge 0 ]]; then
   350          ${flags_completion[${index}]}
   351          return
   352      fi
   353  
   354      # we are parsing a flag and don't have a special handler, no completion
   355      if [[ ${cur} != "${words[cword]}" ]]; then
   356          return
   357      fi
   358  
   359      local completions
   360      completions=("${commands[@]}")
   361      if [[ ${#must_have_one_noun[@]} -ne 0 ]]; then
   362          completions+=("${must_have_one_noun[@]}")
   363      elif [[ -n "${has_completion_function}" ]]; then
   364          # if a go completion function is provided, defer to that function
   365          __s2i_handle_go_custom_completion
   366      fi
   367      if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then
   368          completions+=("${must_have_one_flag[@]}")
   369      fi
   370      while IFS='' read -r comp; do
   371          COMPREPLY+=("$comp")
   372      done < <(compgen -W "${completions[*]}" -- "$cur")
   373  
   374      if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]]; then
   375          while IFS='' read -r comp; do
   376              COMPREPLY+=("$comp")
   377          done < <(compgen -W "${noun_aliases[*]}" -- "$cur")
   378      fi
   379  
   380      if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
   381          if declare -F __s2i_custom_func >/dev/null; then
   382              # try command name qualified custom func
   383              __s2i_custom_func
   384          else
   385              # otherwise fall back to unqualified for compatibility
   386              declare -F __custom_func >/dev/null && __custom_func
   387          fi
   388      fi
   389  
   390      # available in bash-completion >= 2, not always present on macOS
   391      if declare -F __ltrim_colon_completions >/dev/null; then
   392          __ltrim_colon_completions "$cur"
   393      fi
   394  
   395      # If there is only 1 completion and it is a flag with an = it will be completed
   396      # but we don't want a space after the =
   397      if [[ "${#COMPREPLY[@]}" -eq "1" ]] && [[ $(type -t compopt) = "builtin" ]] && [[ "${COMPREPLY[0]}" == --*= ]]; then
   398         compopt -o nospace
   399      fi
   400  }
   401  
   402  # The arguments should be in the form "ext1|ext2|extn"
   403  __s2i_handle_filename_extension_flag()
   404  {
   405      local ext="$1"
   406      _filedir "@(${ext})"
   407  }
   408  
   409  __s2i_handle_subdirs_in_dir_flag()
   410  {
   411      local dir="$1"
   412      pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || return
   413  }
   414  
   415  __s2i_handle_flag()
   416  {
   417      __s2i_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
   418  
   419      # if a command required a flag, and we found it, unset must_have_one_flag()
   420      local flagname=${words[c]}
   421      local flagvalue=""
   422      # if the word contained an =
   423      if [[ ${words[c]} == *"="* ]]; then
   424          flagvalue=${flagname#*=} # take in as flagvalue after the =
   425          flagname=${flagname%=*} # strip everything after the =
   426          flagname="${flagname}=" # but put the = back
   427      fi
   428      __s2i_debug "${FUNCNAME[0]}: looking for ${flagname}"
   429      if __s2i_contains_word "${flagname}" "${must_have_one_flag[@]}"; then
   430          must_have_one_flag=()
   431      fi
   432  
   433      # if you set a flag which only applies to this command, don't show subcommands
   434      if __s2i_contains_word "${flagname}" "${local_nonpersistent_flags[@]}"; then
   435        commands=()
   436      fi
   437  
   438      # keep flag value with flagname as flaghash
   439      # flaghash variable is an associative array which is only supported in bash > 3.
   440      if [[ -z "${BASH_VERSION:-}" || "${BASH_VERSINFO[0]:-}" -gt 3 ]]; then
   441          if [ -n "${flagvalue}" ] ; then
   442              flaghash[${flagname}]=${flagvalue}
   443          elif [ -n "${words[ $((c+1)) ]}" ] ; then
   444              flaghash[${flagname}]=${words[ $((c+1)) ]}
   445          else
   446              flaghash[${flagname}]="true" # pad "true" for bool flag
   447          fi
   448      fi
   449  
   450      # skip the argument to a two word flag
   451      if [[ ${words[c]} != *"="* ]] && __s2i_contains_word "${words[c]}" "${two_word_flags[@]}"; then
   452          __s2i_debug "${FUNCNAME[0]}: found a flag ${words[c]}, skip the next argument"
   453          c=$((c+1))
   454          # if we are looking for a flags value, don't show commands
   455          if [[ $c -eq $cword ]]; then
   456              commands=()
   457          fi
   458      fi
   459  
   460      c=$((c+1))
   461  
   462  }
   463  
   464  __s2i_handle_noun()
   465  {
   466      __s2i_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
   467  
   468      if __s2i_contains_word "${words[c]}" "${must_have_one_noun[@]}"; then
   469          must_have_one_noun=()
   470      elif __s2i_contains_word "${words[c]}" "${noun_aliases[@]}"; then
   471          must_have_one_noun=()
   472      fi
   473  
   474      nouns+=("${words[c]}")
   475      c=$((c+1))
   476  }
   477  
   478  __s2i_handle_command()
   479  {
   480      __s2i_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
   481  
   482      local next_command
   483      if [[ -n ${last_command} ]]; then
   484          next_command="_${last_command}_${words[c]//:/__}"
   485      else
   486          if [[ $c -eq 0 ]]; then
   487              next_command="_s2i_root_command"
   488          else
   489              next_command="_${words[c]//:/__}"
   490          fi
   491      fi
   492      c=$((c+1))
   493      __s2i_debug "${FUNCNAME[0]}: looking for ${next_command}"
   494      declare -F "$next_command" >/dev/null && $next_command
   495  }
   496  
   497  __s2i_handle_word()
   498  {
   499      if [[ $c -ge $cword ]]; then
   500          __s2i_handle_reply
   501          return
   502      fi
   503      __s2i_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
   504      if [[ "${words[c]}" == -* ]]; then
   505          __s2i_handle_flag
   506      elif __s2i_contains_word "${words[c]}" "${commands[@]}"; then
   507          __s2i_handle_command
   508      elif [[ $c -eq 0 ]]; then
   509          __s2i_handle_command
   510      elif __s2i_contains_word "${words[c]}" "${command_aliases[@]}"; then
   511          # aliashash variable is an associative array which is only supported in bash > 3.
   512          if [[ -z "${BASH_VERSION:-}" || "${BASH_VERSINFO[0]:-}" -gt 3 ]]; then
   513              words[c]=${aliashash[${words[c]}]}
   514              __s2i_handle_command
   515          else
   516              __s2i_handle_noun
   517          fi
   518      else
   519          __s2i_handle_noun
   520      fi
   521      __s2i_handle_word
   522  }
   523  
   524  _s2i_build()
   525  {
   526      last_command="s2i_build"
   527  
   528      command_aliases=()
   529  
   530      commands=()
   531  
   532      flags=()
   533      two_word_flags=()
   534      local_nonpersistent_flags=()
   535      flags_with_completion=()
   536      flags_completion=()
   537  
   538      flags+=("--add-host=")
   539      two_word_flags+=("--add-host")
   540      local_nonpersistent_flags+=("--add-host")
   541      local_nonpersistent_flags+=("--add-host=")
   542      flags+=("--allowed-uids=")
   543      two_word_flags+=("--allowed-uids")
   544      two_word_flags+=("-u")
   545      local_nonpersistent_flags+=("--allowed-uids")
   546      local_nonpersistent_flags+=("--allowed-uids=")
   547      local_nonpersistent_flags+=("-u")
   548      flags+=("--application-name=")
   549      two_word_flags+=("--application-name")
   550      two_word_flags+=("-n")
   551      local_nonpersistent_flags+=("--application-name")
   552      local_nonpersistent_flags+=("--application-name=")
   553      local_nonpersistent_flags+=("-n")
   554      flags+=("--as-dockerfile=")
   555      two_word_flags+=("--as-dockerfile")
   556      local_nonpersistent_flags+=("--as-dockerfile")
   557      local_nonpersistent_flags+=("--as-dockerfile=")
   558      flags+=("--assemble-runtime-user=")
   559      two_word_flags+=("--assemble-runtime-user")
   560      local_nonpersistent_flags+=("--assemble-runtime-user")
   561      local_nonpersistent_flags+=("--assemble-runtime-user=")
   562      flags+=("--assemble-user=")
   563      two_word_flags+=("--assemble-user")
   564      local_nonpersistent_flags+=("--assemble-user")
   565      local_nonpersistent_flags+=("--assemble-user=")
   566      flags+=("--callback-url=")
   567      two_word_flags+=("--callback-url")
   568      local_nonpersistent_flags+=("--callback-url")
   569      local_nonpersistent_flags+=("--callback-url=")
   570      flags+=("--cap-drop=")
   571      two_word_flags+=("--cap-drop")
   572      local_nonpersistent_flags+=("--cap-drop")
   573      local_nonpersistent_flags+=("--cap-drop=")
   574      flags+=("--context-dir=")
   575      two_word_flags+=("--context-dir")
   576      local_nonpersistent_flags+=("--context-dir")
   577      local_nonpersistent_flags+=("--context-dir=")
   578      flags+=("--copy")
   579      flags+=("-c")
   580      local_nonpersistent_flags+=("--copy")
   581      local_nonpersistent_flags+=("-c")
   582      flags+=("--description=")
   583      two_word_flags+=("--description")
   584      local_nonpersistent_flags+=("--description")
   585      local_nonpersistent_flags+=("--description=")
   586      flags+=("--destination=")
   587      two_word_flags+=("--destination")
   588      two_word_flags+=("-d")
   589      local_nonpersistent_flags+=("--destination")
   590      local_nonpersistent_flags+=("--destination=")
   591      local_nonpersistent_flags+=("-d")
   592      flags+=("--dockercfg-path=")
   593      two_word_flags+=("--dockercfg-path")
   594      local_nonpersistent_flags+=("--dockercfg-path")
   595      local_nonpersistent_flags+=("--dockercfg-path=")
   596      flags+=("--env=")
   597      two_word_flags+=("--env")
   598      two_word_flags+=("-e")
   599      local_nonpersistent_flags+=("--env")
   600      local_nonpersistent_flags+=("--env=")
   601      local_nonpersistent_flags+=("-e")
   602      flags+=("--environment-file=")
   603      two_word_flags+=("--environment-file")
   604      two_word_flags+=("-E")
   605      local_nonpersistent_flags+=("--environment-file")
   606      local_nonpersistent_flags+=("--environment-file=")
   607      local_nonpersistent_flags+=("-E")
   608      flags+=("--exclude=")
   609      two_word_flags+=("--exclude")
   610      local_nonpersistent_flags+=("--exclude")
   611      local_nonpersistent_flags+=("--exclude=")
   612      flags+=("--ignore-submodules")
   613      local_nonpersistent_flags+=("--ignore-submodules")
   614      flags+=("--image-scripts-url=")
   615      two_word_flags+=("--image-scripts-url")
   616      local_nonpersistent_flags+=("--image-scripts-url")
   617      local_nonpersistent_flags+=("--image-scripts-url=")
   618      flags+=("--incremental")
   619      local_nonpersistent_flags+=("--incremental")
   620      flags+=("--incremental-pull-policy=")
   621      two_word_flags+=("--incremental-pull-policy")
   622      local_nonpersistent_flags+=("--incremental-pull-policy")
   623      local_nonpersistent_flags+=("--incremental-pull-policy=")
   624      flags+=("--inject=")
   625      two_word_flags+=("--inject")
   626      two_word_flags+=("-i")
   627      local_nonpersistent_flags+=("--inject")
   628      local_nonpersistent_flags+=("--inject=")
   629      local_nonpersistent_flags+=("-i")
   630      flags+=("--keep-symlinks")
   631      local_nonpersistent_flags+=("--keep-symlinks")
   632      flags+=("--location=")
   633      two_word_flags+=("--location")
   634      two_word_flags+=("-l")
   635      local_nonpersistent_flags+=("--location")
   636      local_nonpersistent_flags+=("--location=")
   637      local_nonpersistent_flags+=("-l")
   638      flags+=("--network=")
   639      two_word_flags+=("--network")
   640      local_nonpersistent_flags+=("--network")
   641      local_nonpersistent_flags+=("--network=")
   642      flags+=("--pull-policy=")
   643      two_word_flags+=("--pull-policy")
   644      two_word_flags+=("-p")
   645      local_nonpersistent_flags+=("--pull-policy")
   646      local_nonpersistent_flags+=("--pull-policy=")
   647      local_nonpersistent_flags+=("-p")
   648      flags+=("--quiet")
   649      flags+=("-q")
   650      local_nonpersistent_flags+=("--quiet")
   651      local_nonpersistent_flags+=("-q")
   652      flags+=("--ref=")
   653      two_word_flags+=("--ref")
   654      two_word_flags+=("-r")
   655      local_nonpersistent_flags+=("--ref")
   656      local_nonpersistent_flags+=("--ref=")
   657      local_nonpersistent_flags+=("-r")
   658      flags+=("--rm")
   659      local_nonpersistent_flags+=("--rm")
   660      flags+=("--run")
   661      local_nonpersistent_flags+=("--run")
   662      flags+=("--runtime-artifact=")
   663      two_word_flags+=("--runtime-artifact")
   664      two_word_flags+=("-a")
   665      local_nonpersistent_flags+=("--runtime-artifact")
   666      local_nonpersistent_flags+=("--runtime-artifact=")
   667      local_nonpersistent_flags+=("-a")
   668      flags+=("--runtime-image=")
   669      two_word_flags+=("--runtime-image")
   670      local_nonpersistent_flags+=("--runtime-image")
   671      local_nonpersistent_flags+=("--runtime-image=")
   672      flags+=("--runtime-pull-policy=")
   673      two_word_flags+=("--runtime-pull-policy")
   674      local_nonpersistent_flags+=("--runtime-pull-policy")
   675      local_nonpersistent_flags+=("--runtime-pull-policy=")
   676      flags+=("--save-temp-dir")
   677      local_nonpersistent_flags+=("--save-temp-dir")
   678      flags+=("--scripts=")
   679      two_word_flags+=("--scripts")
   680      local_nonpersistent_flags+=("--scripts")
   681      local_nonpersistent_flags+=("--scripts=")
   682      flags+=("--scripts-url=")
   683      two_word_flags+=("--scripts-url")
   684      two_word_flags+=("-s")
   685      local_nonpersistent_flags+=("--scripts-url")
   686      local_nonpersistent_flags+=("--scripts-url=")
   687      local_nonpersistent_flags+=("-s")
   688      flags+=("--use-config")
   689      local_nonpersistent_flags+=("--use-config")
   690      flags+=("--volume=")
   691      two_word_flags+=("--volume")
   692      two_word_flags+=("-v")
   693      local_nonpersistent_flags+=("--volume")
   694      local_nonpersistent_flags+=("--volume=")
   695      local_nonpersistent_flags+=("-v")
   696      flags+=("--ca=")
   697      two_word_flags+=("--ca")
   698      flags+=("--cert=")
   699      two_word_flags+=("--cert")
   700      flags+=("--key=")
   701      two_word_flags+=("--key")
   702      flags+=("--loglevel=")
   703      two_word_flags+=("--loglevel")
   704      flags+=("--tls")
   705      flags+=("--tlsverify")
   706      flags+=("--url=")
   707      two_word_flags+=("--url")
   708      two_word_flags+=("-U")
   709  
   710      must_have_one_flag=()
   711      must_have_one_noun=()
   712      noun_aliases=()
   713  }
   714  
   715  _s2i_completion()
   716  {
   717      last_command="s2i_completion"
   718  
   719      command_aliases=()
   720  
   721      commands=()
   722  
   723      flags=()
   724      two_word_flags=()
   725      local_nonpersistent_flags=()
   726      flags_with_completion=()
   727      flags_completion=()
   728  
   729      flags+=("--help")
   730      flags+=("-h")
   731      local_nonpersistent_flags+=("--help")
   732      local_nonpersistent_flags+=("-h")
   733      flags+=("--ca=")
   734      two_word_flags+=("--ca")
   735      flags+=("--cert=")
   736      two_word_flags+=("--cert")
   737      flags+=("--key=")
   738      two_word_flags+=("--key")
   739      flags+=("--loglevel=")
   740      two_word_flags+=("--loglevel")
   741      flags+=("--tls")
   742      flags+=("--tlsverify")
   743      flags+=("--url=")
   744      two_word_flags+=("--url")
   745      two_word_flags+=("-U")
   746  
   747      must_have_one_flag=()
   748      must_have_one_noun=()
   749      must_have_one_noun+=("bash")
   750      must_have_one_noun+=("zsh")
   751      noun_aliases=()
   752  }
   753  
   754  _s2i_create()
   755  {
   756      last_command="s2i_create"
   757  
   758      command_aliases=()
   759  
   760      commands=()
   761  
   762      flags=()
   763      two_word_flags=()
   764      local_nonpersistent_flags=()
   765      flags_with_completion=()
   766      flags_completion=()
   767  
   768      flags+=("--ca=")
   769      two_word_flags+=("--ca")
   770      flags+=("--cert=")
   771      two_word_flags+=("--cert")
   772      flags+=("--key=")
   773      two_word_flags+=("--key")
   774      flags+=("--loglevel=")
   775      two_word_flags+=("--loglevel")
   776      flags+=("--tls")
   777      flags+=("--tlsverify")
   778      flags+=("--url=")
   779      two_word_flags+=("--url")
   780      two_word_flags+=("-U")
   781  
   782      must_have_one_flag=()
   783      must_have_one_noun=()
   784      noun_aliases=()
   785  }
   786  
   787  _s2i_generate()
   788  {
   789      last_command="s2i_generate"
   790  
   791      command_aliases=()
   792  
   793      commands=()
   794  
   795      flags=()
   796      two_word_flags=()
   797      local_nonpersistent_flags=()
   798      flags_with_completion=()
   799      flags_completion=()
   800  
   801      flags+=("--assemble-runtime-user=")
   802      two_word_flags+=("--assemble-runtime-user")
   803      local_nonpersistent_flags+=("--assemble-runtime-user")
   804      local_nonpersistent_flags+=("--assemble-runtime-user=")
   805      flags+=("--assemble-user=")
   806      two_word_flags+=("--assemble-user")
   807      local_nonpersistent_flags+=("--assemble-user")
   808      local_nonpersistent_flags+=("--assemble-user=")
   809      flags+=("--env=")
   810      two_word_flags+=("--env")
   811      two_word_flags+=("-e")
   812      local_nonpersistent_flags+=("--env")
   813      local_nonpersistent_flags+=("--env=")
   814      local_nonpersistent_flags+=("-e")
   815      flags+=("--quiet")
   816      flags+=("-q")
   817      local_nonpersistent_flags+=("--quiet")
   818      local_nonpersistent_flags+=("-q")
   819      flags+=("--ca=")
   820      two_word_flags+=("--ca")
   821      flags+=("--cert=")
   822      two_word_flags+=("--cert")
   823      flags+=("--key=")
   824      two_word_flags+=("--key")
   825      flags+=("--loglevel=")
   826      two_word_flags+=("--loglevel")
   827      flags+=("--tls")
   828      flags+=("--tlsverify")
   829      flags+=("--url=")
   830      two_word_flags+=("--url")
   831      two_word_flags+=("-U")
   832  
   833      must_have_one_flag=()
   834      must_have_one_noun=()
   835      noun_aliases=()
   836  }
   837  
   838  _s2i_help()
   839  {
   840      last_command="s2i_help"
   841  
   842      command_aliases=()
   843  
   844      commands=()
   845  
   846      flags=()
   847      two_word_flags=()
   848      local_nonpersistent_flags=()
   849      flags_with_completion=()
   850      flags_completion=()
   851  
   852      flags+=("--ca=")
   853      two_word_flags+=("--ca")
   854      flags+=("--cert=")
   855      two_word_flags+=("--cert")
   856      flags+=("--key=")
   857      two_word_flags+=("--key")
   858      flags+=("--loglevel=")
   859      two_word_flags+=("--loglevel")
   860      flags+=("--tls")
   861      flags+=("--tlsverify")
   862      flags+=("--url=")
   863      two_word_flags+=("--url")
   864      two_word_flags+=("-U")
   865  
   866      must_have_one_flag=()
   867      must_have_one_noun=()
   868      has_completion_function=1
   869      noun_aliases=()
   870  }
   871  
   872  _s2i_rebuild()
   873  {
   874      last_command="s2i_rebuild"
   875  
   876      command_aliases=()
   877  
   878      commands=()
   879  
   880      flags=()
   881      two_word_flags=()
   882      local_nonpersistent_flags=()
   883      flags_with_completion=()
   884      flags_completion=()
   885  
   886      flags+=("--callback-url=")
   887      two_word_flags+=("--callback-url")
   888      local_nonpersistent_flags+=("--callback-url")
   889      local_nonpersistent_flags+=("--callback-url=")
   890      flags+=("--destination=")
   891      two_word_flags+=("--destination")
   892      two_word_flags+=("-d")
   893      local_nonpersistent_flags+=("--destination")
   894      local_nonpersistent_flags+=("--destination=")
   895      local_nonpersistent_flags+=("-d")
   896      flags+=("--dockercfg-path=")
   897      two_word_flags+=("--dockercfg-path")
   898      local_nonpersistent_flags+=("--dockercfg-path")
   899      local_nonpersistent_flags+=("--dockercfg-path=")
   900      flags+=("--incremental")
   901      local_nonpersistent_flags+=("--incremental")
   902      flags+=("--incremental-pull-policy=")
   903      two_word_flags+=("--incremental-pull-policy")
   904      local_nonpersistent_flags+=("--incremental-pull-policy")
   905      local_nonpersistent_flags+=("--incremental-pull-policy=")
   906      flags+=("--pull-policy=")
   907      two_word_flags+=("--pull-policy")
   908      two_word_flags+=("-p")
   909      local_nonpersistent_flags+=("--pull-policy")
   910      local_nonpersistent_flags+=("--pull-policy=")
   911      local_nonpersistent_flags+=("-p")
   912      flags+=("--quiet")
   913      flags+=("-q")
   914      local_nonpersistent_flags+=("--quiet")
   915      local_nonpersistent_flags+=("-q")
   916      flags+=("--rm")
   917      local_nonpersistent_flags+=("--rm")
   918      flags+=("--runtime-pull-policy=")
   919      two_word_flags+=("--runtime-pull-policy")
   920      local_nonpersistent_flags+=("--runtime-pull-policy")
   921      local_nonpersistent_flags+=("--runtime-pull-policy=")
   922      flags+=("--save-temp-dir")
   923      local_nonpersistent_flags+=("--save-temp-dir")
   924      flags+=("--ca=")
   925      two_word_flags+=("--ca")
   926      flags+=("--cert=")
   927      two_word_flags+=("--cert")
   928      flags+=("--key=")
   929      two_word_flags+=("--key")
   930      flags+=("--loglevel=")
   931      two_word_flags+=("--loglevel")
   932      flags+=("--tls")
   933      flags+=("--tlsverify")
   934      flags+=("--url=")
   935      two_word_flags+=("--url")
   936      two_word_flags+=("-U")
   937  
   938      must_have_one_flag=()
   939      must_have_one_noun=()
   940      noun_aliases=()
   941  }
   942  
   943  _s2i_usage()
   944  {
   945      last_command="s2i_usage"
   946  
   947      command_aliases=()
   948  
   949      commands=()
   950  
   951      flags=()
   952      two_word_flags=()
   953      local_nonpersistent_flags=()
   954      flags_with_completion=()
   955      flags_completion=()
   956  
   957      flags+=("--callback-url=")
   958      two_word_flags+=("--callback-url")
   959      local_nonpersistent_flags+=("--callback-url")
   960      local_nonpersistent_flags+=("--callback-url=")
   961      flags+=("--destination=")
   962      two_word_flags+=("--destination")
   963      two_word_flags+=("-d")
   964      local_nonpersistent_flags+=("--destination")
   965      local_nonpersistent_flags+=("--destination=")
   966      local_nonpersistent_flags+=("-d")
   967      flags+=("--dockercfg-path=")
   968      two_word_flags+=("--dockercfg-path")
   969      local_nonpersistent_flags+=("--dockercfg-path")
   970      local_nonpersistent_flags+=("--dockercfg-path=")
   971      flags+=("--incremental")
   972      local_nonpersistent_flags+=("--incremental")
   973      flags+=("--incremental-pull-policy=")
   974      two_word_flags+=("--incremental-pull-policy")
   975      local_nonpersistent_flags+=("--incremental-pull-policy")
   976      local_nonpersistent_flags+=("--incremental-pull-policy=")
   977      flags+=("--location=")
   978      two_word_flags+=("--location")
   979      two_word_flags+=("-l")
   980      local_nonpersistent_flags+=("--location")
   981      local_nonpersistent_flags+=("--location=")
   982      local_nonpersistent_flags+=("-l")
   983      flags+=("--pull-policy=")
   984      two_word_flags+=("--pull-policy")
   985      two_word_flags+=("-p")
   986      local_nonpersistent_flags+=("--pull-policy")
   987      local_nonpersistent_flags+=("--pull-policy=")
   988      local_nonpersistent_flags+=("-p")
   989      flags+=("--quiet")
   990      flags+=("-q")
   991      local_nonpersistent_flags+=("--quiet")
   992      local_nonpersistent_flags+=("-q")
   993      flags+=("--rm")
   994      local_nonpersistent_flags+=("--rm")
   995      flags+=("--runtime-pull-policy=")
   996      two_word_flags+=("--runtime-pull-policy")
   997      local_nonpersistent_flags+=("--runtime-pull-policy")
   998      local_nonpersistent_flags+=("--runtime-pull-policy=")
   999      flags+=("--save-temp-dir")
  1000      local_nonpersistent_flags+=("--save-temp-dir")
  1001      flags+=("--ca=")
  1002      two_word_flags+=("--ca")
  1003      flags+=("--cert=")
  1004      two_word_flags+=("--cert")
  1005      flags+=("--key=")
  1006      two_word_flags+=("--key")
  1007      flags+=("--loglevel=")
  1008      two_word_flags+=("--loglevel")
  1009      flags+=("--tls")
  1010      flags+=("--tlsverify")
  1011      flags+=("--url=")
  1012      two_word_flags+=("--url")
  1013      two_word_flags+=("-U")
  1014  
  1015      must_have_one_flag=()
  1016      must_have_one_noun=()
  1017      noun_aliases=()
  1018  }
  1019  
  1020  _s2i_version()
  1021  {
  1022      last_command="s2i_version"
  1023  
  1024      command_aliases=()
  1025  
  1026      commands=()
  1027  
  1028      flags=()
  1029      two_word_flags=()
  1030      local_nonpersistent_flags=()
  1031      flags_with_completion=()
  1032      flags_completion=()
  1033  
  1034      flags+=("--ca=")
  1035      two_word_flags+=("--ca")
  1036      flags+=("--cert=")
  1037      two_word_flags+=("--cert")
  1038      flags+=("--key=")
  1039      two_word_flags+=("--key")
  1040      flags+=("--loglevel=")
  1041      two_word_flags+=("--loglevel")
  1042      flags+=("--tls")
  1043      flags+=("--tlsverify")
  1044      flags+=("--url=")
  1045      two_word_flags+=("--url")
  1046      two_word_flags+=("-U")
  1047  
  1048      must_have_one_flag=()
  1049      must_have_one_noun=()
  1050      noun_aliases=()
  1051  }
  1052  
  1053  _s2i_root_command()
  1054  {
  1055      last_command="s2i"
  1056  
  1057      command_aliases=()
  1058  
  1059      commands=()
  1060      commands+=("build")
  1061      commands+=("completion")
  1062      commands+=("create")
  1063      commands+=("generate")
  1064      commands+=("help")
  1065      commands+=("rebuild")
  1066      commands+=("usage")
  1067      commands+=("version")
  1068  
  1069      flags=()
  1070      two_word_flags=()
  1071      local_nonpersistent_flags=()
  1072      flags_with_completion=()
  1073      flags_completion=()
  1074  
  1075      flags+=("--ca=")
  1076      two_word_flags+=("--ca")
  1077      flags+=("--cert=")
  1078      two_word_flags+=("--cert")
  1079      flags+=("--key=")
  1080      two_word_flags+=("--key")
  1081      flags+=("--loglevel=")
  1082      two_word_flags+=("--loglevel")
  1083      flags+=("--tls")
  1084      flags+=("--tlsverify")
  1085      flags+=("--url=")
  1086      two_word_flags+=("--url")
  1087      two_word_flags+=("-U")
  1088  
  1089      must_have_one_flag=()
  1090      must_have_one_noun=()
  1091      noun_aliases=()
  1092  }
  1093  
  1094  __start_s2i()
  1095  {
  1096      local cur prev words cword split
  1097      declare -A flaghash 2>/dev/null || :
  1098      declare -A aliashash 2>/dev/null || :
  1099      if declare -F _init_completion >/dev/null 2>&1; then
  1100          _init_completion -s || return
  1101      else
  1102          __s2i_init_completion -n "=" || return
  1103      fi
  1104  
  1105      local c=0
  1106      local flag_parsing_disabled=
  1107      local flags=()
  1108      local two_word_flags=()
  1109      local local_nonpersistent_flags=()
  1110      local flags_with_completion=()
  1111      local flags_completion=()
  1112      local commands=("s2i")
  1113      local command_aliases=()
  1114      local must_have_one_flag=()
  1115      local must_have_one_noun=()
  1116      local has_completion_function=""
  1117      local last_command=""
  1118      local nouns=()
  1119      local noun_aliases=()
  1120  
  1121      __s2i_handle_word
  1122  }
  1123  
  1124  if [[ $(type -t compopt) = "builtin" ]]; then
  1125      complete -o default -F __start_s2i s2i
  1126  else
  1127      complete -o default -o nospace -F __start_s2i s2i
  1128  fi
  1129  
  1130  # ex: ts=4 sw=4 et filetype=sh
  1131  
  1132  BASH_COMPLETION_EOF
  1133  }
  1134  
  1135  __kubectl_bash_source <(__kubectl_convert_bash_to_zsh)