github.com/containerd/Containerd@v1.4.13/contrib/autocomplete/ctr (about)

     1  #! /bin/bash
     2  ## This file is a direct copy of https://github.com/urfave/cli/blob/d04c0883fcc8860836ab30ade0fd29afa194ab23/autocomplete/bash_autocomplete
     3  
     4  : ${PROG:=$(basename ${BASH_SOURCE})}
     5  
     6  _cli_bash_autocomplete() {
     7    if [[ "${COMP_WORDS[0]}" != "source" ]]; then
     8      local cur opts base
     9      COMPREPLY=()
    10      cur="${COMP_WORDS[COMP_CWORD]}"
    11      if [[ "$cur" == "-"* ]]; then
    12        opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion )
    13      else
    14        opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
    15      fi
    16      COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
    17      return 0
    18    fi
    19  }
    20  
    21  complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG
    22  unset PROG