iron.git

ref: 05ebf895ec62c8cd2ac00de2808aaa5da03f5f3a

iron/completions/sub.bash


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
_sub() {
  COMPREPLY=()
  local word="${COMP_WORDS[COMP_CWORD]}"

  if [ "$COMP_CWORD" -eq 1 ]; then
    COMPREPLY=( $(compgen -W "$(sub commands)" -- "$word") )
  else
    local command="${COMP_WORDS[1]}"
    local completions="$(sub completions "$command")"
    COMPREPLY=( $(compgen -W "$completions" -- "$word") )
  fi
}

complete -F _sub sub