you-get-completion.bash 916 B

12345678910111213141516171819202122232425262728293031
  1. # Bash completion definition for you-get.
  2. _you-get () {
  3. COMPREPLY=()
  4. local IFS=$' \n'
  5. local cur=$2 prev=$3
  6. local -a opts_without_arg opts_with_arg
  7. opts_without_arg=(
  8. -V --version -h --help -i --info -u --url --json -n --no-merge
  9. --no-caption -f --force --no-proxy -d --debug
  10. )
  11. opts_with_arg=(
  12. -F --format -O --output-filename -o --output-dir -p --player
  13. -c --cookies -x --http-proxy -y --extractor-proxy -t --timeout
  14. )
  15. # Do not complete non option names
  16. [[ $cur == -* ]] || return 1
  17. # Do not complete when the previous arg is an option expecting an argument
  18. for opt in "${opts_with_arg[@]}"; do
  19. [[ $opt == $prev ]] && return 1
  20. done
  21. # Complete option names
  22. COMPREPLY=( $(compgen -W "${opts_without_arg[*]} ${opts_with_arg[*]}" \
  23. -- "$cur") )
  24. return 0
  25. }
  26. complete -F _you-get you-get