You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

completion.sh 1.4 KiB

1 jaar geleden
12345678910111213141516171819202122232425262728293031323334353637
  1. _bench_completion() {
  2. # Complete commands using click bashcomplete
  3. COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \
  4. COMP_CWORD=$COMP_CWORD \
  5. _BENCH_COMPLETE=complete $1 ) )
  6. if [ -d "sites" ]; then
  7. # Also add xhiveframework commands if present
  8. # bench_helper.py expects to be executed from "sites" directory
  9. cd sites
  10. # All xhiveframework commands are subcommands under "bench xhiveframework"
  11. # Xhiveframework is only installed in virtualenv "env" so use appropriate python executable
  12. COMPREPLY+=( $( COMP_WORDS="bench xhiveframework "${COMP_WORDS[@]:1} \
  13. COMP_CWORD=$(($COMP_CWORD+1)) \
  14. _BENCH_COMPLETE=complete ../env/bin/python ../apps/xhiveframework/xhiveframework/utils/bench_helper.py ) )
  15. # If the word before the current cursor position in command typed so far is "--site" then only list sites
  16. if [ ${COMP_WORDS[COMP_CWORD-1]} == "--site" ]; then
  17. COMPREPLY=( $( ls -d ./*/site_config.json | cut -f 2 -d "/" | xargs echo ) )
  18. fi
  19. # Get out of sites directory now
  20. cd ..
  21. fi
  22. return 0
  23. }
  24. # Only support bash and zsh
  25. if [ -n "$BASH" ] ; then
  26. complete -F _bench_completion -o default bench;
  27. elif [ -n "$ZSH_VERSION" ]; then
  28. # Use zsh in bash compatibility mode
  29. autoload bashcompinit
  30. bashcompinit
  31. complete -F _bench_completion -o default bench;
  32. fi