auto-complete 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/usr/bin/env bash
  2. _drk()
  3. {
  4. local cur prev opts
  5. COMPREPLY=()
  6. cur="${COMP_WORDS[COMP_CWORD]}"
  7. prev="${COMP_WORDS[COMP_CWORD-1]}"
  8. # don't complet =
  9. _init_completion -n = || return
  10. opts="-h"
  11. opts+=" -c "
  12. opts+=" -v "
  13. opts+=" -V"
  14. opts+=" deposit"
  15. opts+=" features"
  16. opts+=" hello"
  17. opts+=" help"
  18. opts+=" id"
  19. opts+=" transfer"
  20. opts+=" wallet"
  21. opts+=" withdraw"
  22. # Prevent word reuse
  23. lim=$((COMP_CWORD - 1))
  24. for i in $( seq 0 $lim )
  25. do
  26. if [[ $opts == *"${COMP_WORDS[i]}"* ]]; then
  27. opts=${opts//${COMP_WORDS[i]}/}
  28. opts=${opts//--${COMP_WORDS[i]}/}
  29. fi
  30. done
  31. # case $prev in
  32. # -v)
  33. # opts=$(./drk --verbose | sed -e '$d')
  34. # COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
  35. # return 0
  36. # ;;
  37. # esac
  38. #
  39. # case $prev in
  40. # --V)
  41. # opts=$(./drk --version | sed -e '$d')
  42. # COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
  43. # return 0
  44. # ;;
  45. # esac
  46. COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") $(compgen -W "${opts}" -- ${cur}) )
  47. [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
  48. }
  49. complete -F _drk drk
  50. _darkfid()
  51. {
  52. local cur prev opts
  53. COMPREPLY=()
  54. cur="${COMP_WORDS[COMP_CWORD]}"
  55. prev="${COMP_WORDS[COMP_CWORD-1]}"
  56. _init_completion -n = || return
  57. opts="-h"
  58. opts+=" -c "
  59. opts+=" -v "
  60. opts+=" -V"
  61. lim=$((COMP_CWORD - 1))
  62. for i in $( seq 0 $lim )
  63. do
  64. if [[ $opts == *"${COMP_WORDS[i]}"* ]]; then
  65. opts=${opts//${COMP_WORDS[i]}/}
  66. opts=${opts//--${COMP_WORDS[i]}/}
  67. fi
  68. done
  69. COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") $(compgen -W "${opts}" -- ${cur}) )
  70. [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
  71. }
  72. complete -F _darkfid darkfid