pisilinux 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. _pisi()
  2. {
  3. local cur command commands options packages files
  4. COMPREPLY=()
  5. cur=${COMP_WORDS[COMP_CWORD]}
  6. commands="add-repo build check clean configure-pending delete-cache delta \
  7. emerge graph help history index info install list-available \
  8. list-components list-installed list-newest list-pending list-repo \
  9. list-sources list-upgrades rebuild-db remove remove-repo search \
  10. search-file update-repo upgrade"
  11. options="--destdir --yes-all --username --password --bandwidth-limit --verbose \
  12. --debug --no-color"
  13. packages=""
  14. files=""
  15. if [[ $COMP_CWORD -eq 1 ]] ; then
  16. if [[ "$cur" == -* ]]; then
  17. COMPREPLY=($(compgen -W "--version --help" -- $cur))
  18. else
  19. COMPREPLY=($(compgen -W "$commands --version --help" -- $cur))
  20. fi
  21. return 0;
  22. else
  23. command=${COMP_WORDS[1]}
  24. if [[ "$cur" == -* ]]; then
  25. case $command in
  26. @(add-repo|ar))
  27. options="${options} --at --ignore-check"
  28. ;;
  29. @(blame|bl))
  30. options="${options} --release --all"
  31. ;;
  32. @(build|bi))
  33. options="${options} --fetch --unpack --setup --build \
  34. --check --install --package --ignore-build-no \
  35. --quiet --ignore-dependency --output-dir \
  36. --ignore-action-errors --ignore-safety \
  37. --ignore-check --create-static --package-format \
  38. --use-quilt --ignore-sandbox"
  39. ;;
  40. @(check))
  41. options="${options} --component --config"
  42. ;;
  43. @(clean))
  44. options="${options}"
  45. ;;
  46. @(configure-pending|cp))
  47. options="${options} --ignore-dependency --ignore-comar \
  48. --ignore-safety --dry-run"
  49. ;;
  50. @(delete-cache|dc))
  51. options="${options}"
  52. ;;
  53. @(delta|dt))
  54. options="${options} --output-dir"
  55. ;;
  56. @(disable-repo|dr))
  57. options="${options}"
  58. ;;
  59. @(emerge|em))
  60. options="${options} --ignore-build-no --quiet --ignore-dependency \
  61. --output-dir --ignore-action-errors --ignore safety \
  62. --ignore-check --create-static --package-format \
  63. --use-quilt --ignore-sandbox --component \
  64. --ignore-file-conflicts --ignore-package-conflicts --ignore-comar"
  65. ;;
  66. @(enable-repo|er))
  67. options="${options}"
  68. ;;
  69. @(fetch|fc))
  70. options="${options} --output-dir"
  71. ;;
  72. @(graph))
  73. options="${options} --reporsitory --installed \
  74. --ignore-installed --output"
  75. ;;
  76. @(help|--help))
  77. options="${commands}"
  78. ;;
  79. @(history|hs))
  80. options="${options} --last --snapshot --takeback"
  81. ;;
  82. @(index|ix))
  83. options="${options} --absolute-urls --output --skip-sources \
  84. --skip-signing"
  85. ;;
  86. @(info))
  87. options="${options} --files --component --files-path --short --xml"
  88. ;;
  89. @(install|it))
  90. options="${options} --ignore-dependency --ignore-comar \
  91. --ignore-safety --dry-run --ignore-build-no \
  92. --reinstall --ignore-check --ignore-file-conflicts \
  93. --ignore-package-conflicts --component --repository \
  94. --fetch-only --exclude --exclude-from"
  95. ;;
  96. @(list-available|la))
  97. options="${options} --long --component --uninstalled"
  98. ;;
  99. @(list-components|lc))
  100. options="${options} --long --repository"
  101. ;;
  102. @(list-installed|li))
  103. options="${options} --without-buildno --long --component --install-info"
  104. ;;
  105. @(list-newest|ln))
  106. options="${options} --since --last"
  107. ;;
  108. @(list-pending|lp))
  109. options="${options}"
  110. ;;
  111. @(list-repo|lr))
  112. options="${options}"
  113. ;;
  114. @(list-sources|ls))
  115. options="${options} --long"
  116. ;;
  117. @(list-upgrades|lu))
  118. options="${options} --ignore-build-no --long --component \
  119. --install-info"
  120. ;;
  121. @(rebuild-db|rdb))
  122. options="${options} --files"
  123. ;;
  124. @(remove|rm))
  125. options="${options} --ignore-dependency --ignore-comar \
  126. --ignore-safety --dry-run --purge --component"
  127. ;;
  128. @(remove-repo|rr))
  129. options="${options}"
  130. ;;
  131. @(search|sr))
  132. options="${options} --language --repository --installdb \
  133. --sourcedb --name --summary --description"
  134. ;;
  135. @(search-file|sf))
  136. options="${options} --long --quiet"
  137. ;;
  138. @(update-repo|ur))
  139. options="${options} --force"
  140. ;;
  141. @(upgrade|up))
  142. options="${options} --ignore-dependency --ignore-comar \
  143. --ignore-safety --dry-run --ignore-build-no \
  144. --security-only --bypass-update-repo \
  145. --ignore-file-conflicts --ignore-package-conflicts \
  146. --component --repository --fetch-only --exclude --exclude-from"
  147. ;;
  148. esac
  149. COMPREPLY=($(compgen -W "$options" -- $cur))
  150. return 0;
  151. else
  152. case $command in
  153. @(install|it))
  154. if [ `ls *.pisi 2> /dev/null | wc -l` -gt 0 ]; then
  155. packages=""
  156. else
  157. if `ls /var/lib/pisi/index/* &>/dev/null`; then
  158. packages=`grep -P "<Name>[^\s]*</Name>" /var/lib/pisi/index/*/pisi-index.xml | gawk -F '>' '{print $2}' | gawk -F '<' '{print $1}' | sort | uniq | tr "\n" " "`
  159. fi
  160. fi
  161. ;;
  162. @(info))
  163. if `ls /var/lib/pisi/index/* &>/dev/null`; then
  164. packages=`grep -P "<Name>[^\s]*</Name>" /var/lib/pisi/index/*/pisi-index.xml | gawk -F '>' '{print $2}' | gawk -F '<' '{print $1}' | sort | uniq | tr "\n" " "`
  165. fi
  166. ;;
  167. @(upgrade|up|remove|rm))
  168. if `ls /var/lib/pisi/index/* &>/dev/null`; then
  169. packages=`grep -P "<Name>[^\s]*</Name>" /var/lib/pisi/package/*/metadata.xml | gawk -F '>' '{print $2}' | gawk -F '<' '{print $1}' | sort | uniq | tr "\n" " "`
  170. fi
  171. ;;
  172. esac
  173. COMPREPLY=($(compgen -f -W "$packages" -- $cur))
  174. return 0;
  175. fi
  176. fi
  177. _filedir '@(pisi)'
  178. }
  179. complete -F _pisi -o filenames pisi
  180. _service()
  181. {
  182. local list
  183. COMPREPLY=()
  184. cur="${COMP_WORDS[COMP_CWORD]}"
  185. cur_num=${#COMP_WORDS[*]}
  186. if [[ ${cur_num} == 2 ]]; then
  187. list=`/usr/bin/hav list-apps System.Service`
  188. COMPREPLY=($(compgen -W "${list} dbus" -- ${cur}))
  189. elif [[ ${cur_num} -ge 3 ]]; then
  190. COMPREPLY=($(compgen -W "on off start stop restart reload" -- ${cur}))
  191. fi
  192. }
  193. complete -F _service service
  194. _hav()
  195. {
  196. local list command app model
  197. list=""
  198. COMPREPLY=()
  199. cur="${COMP_WORDS[COMP_CWORD]}"
  200. cur_num=${#COMP_WORDS[*]}
  201. if [[ ${cur_num} == 2 ]]; then
  202. COMPREPLY=($(compgen -W "call list-apps list-models list-methods register remove" -- ${cur}))
  203. elif [[ ${cur_num} == 3 ]]; then
  204. command=${COMP_WORDS[1]}
  205. case $command in
  206. @(call))
  207. list=`/usr/bin/hav list-apps`
  208. ;;
  209. @(list-models|list-methods|register|remove))
  210. list=`/usr/bin/hav list-apps`
  211. ;;
  212. esac
  213. COMPREPLY=($(compgen -W "${list}" -- ${cur}))
  214. elif [[ ${cur_num} == 4 ]]; then
  215. command=${COMP_WORDS[1]}
  216. app=${COMP_WORDS[2]}
  217. case $command in
  218. @(call))
  219. list=`/usr/bin/hav list-models ${app}`
  220. ;;
  221. esac
  222. COMPREPLY=($(compgen -W "${list}" -- ${cur}))
  223. elif [[ ${cur_num} == 5 ]]; then
  224. command=${COMP_WORDS[1]}
  225. app=${COMP_WORDS[2]}
  226. model=${COMP_WORDS[3]}
  227. case $command in
  228. @(call))
  229. list=`/usr/bin/hav list-methods ${app} ${model}`
  230. ;;
  231. esac
  232. COMPREPLY=($(compgen -W "${list}" -- ${cur}))
  233. fi
  234. }
  235. complete -F _hav hav