/bash_completion.d/mock

http://github.com/brinkman83/bashrc · #! · 85 lines · 77 code · 8 blank · 0 comment · 0 complexity · b8738aadbcb60e248fe826b26865e435 MD5 · raw file

  1. # bash completion for mock
  2. have mock &&
  3. _mock()
  4. {
  5. local cur prev plugins cfgdir split=false
  6. COMPREPLY=()
  7. cur=`_get_cword`
  8. prev=${COMP_WORDS[COMP_CWORD-1]}
  9. plugins='tmpfs root_cache yum_cache bind_mount ccache'
  10. cfgdir=/etc/mock
  11. count=0
  12. for i in "${COMP_WORDS[@]}" ; do
  13. [ $count -eq $COMP_CWORD ] && break
  14. if [[ "$i" == --configdir ]] ; then
  15. cfgdir="${COMP_WORDS[((count+1))]}"
  16. elif [[ "$i" == --configdir=* ]] ; then
  17. cfgdir=${i/*=/}
  18. fi
  19. count=$((++count))
  20. done
  21. _split_longopt && split=true
  22. case $prev in
  23. -@(h|-help|-copy@(in|out)|-arch|D|-define|-with?(out)|-uniqueext|-rpmbuild_timeout|-sources|-cwd))
  24. return 0
  25. ;;
  26. -r|--root)
  27. COMPREPLY=( $( compgen -W "$( command ls $cfgdir )" -- $cur ) )
  28. COMPREPLY=( ${COMPREPLY[@]/%.cfg/} )
  29. return 0
  30. ;;
  31. --@(config|result)dir)
  32. _filedir -d
  33. return 0
  34. ;;
  35. --spec)
  36. _filedir spec
  37. return 0
  38. ;;
  39. --target)
  40. # Yep, compatible archs, not compatible build archs
  41. # (e.g. ix86 chroot builds in x86_64 mock host)
  42. # This would actually depend on what the target root
  43. # can be used to build for...
  44. COMPREPLY=( $( compgen -W "$( command rpm --showrc | \
  45. sed -ne 's/^\s*compatible\s\+archs\s*:\s*\(.*\)/\1/i p' )" \
  46. -- "$cur" ) )
  47. return 0
  48. ;;
  49. --@(en|dis)able-plugin)
  50. COMPREPLY=( $( compgen -W "$plugins" -- "$cur" ) )
  51. return 0
  52. ;;
  53. esac
  54. $split && return 0
  55. if [[ "$cur" == -* ]] ; then
  56. COMPREPLY=( $( compgen -W '--version -h --help --rebuild \
  57. --buildsrpm --shell --chroot --clean --init \
  58. --installdeps --install --update --orphanskill \
  59. --copyin --copyout -r --root --offline --no-clean \
  60. --cleanup-after --no-cleanup-after --arch --target \
  61. -D --define --with --without --resultdir --uniqueext \
  62. --configdir --rpmbuild_timeout --unpriv --cwd --spec \
  63. --sources -v --verbose -q --quiet --trace \
  64. --enable-plugin --disable-plugin --print-root-path' \
  65. -- "$cur" ) )
  66. else
  67. _filedir '?(no)src.rpm'
  68. fi
  69. } &&
  70. complete -F _mock $filenames mock
  71. # Local variables:
  72. # mode: shell-script
  73. # sh-basic-offset: 4
  74. # sh-indent-comment: t
  75. # indent-tabs-mode: nil
  76. # End:
  77. # ex: ts=4 sw=4 et filetype=sh