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.

170 lines
4.9KB

  1. _gutenberg() {
  2. local i cur prev opts cmds
  3. COMPREPLY=()
  4. cur="${COMP_WORDS[COMP_CWORD]}"
  5. prev="${COMP_WORDS[COMP_CWORD-1]}"
  6. cmd=""
  7. opts=""
  8. for i in ${COMP_WORDS[@]}
  9. do
  10. case "${i}" in
  11. gutenberg)
  12. cmd="gutenberg"
  13. ;;
  14. build)
  15. cmd+="__build"
  16. ;;
  17. help)
  18. cmd+="__help"
  19. ;;
  20. init)
  21. cmd+="__init"
  22. ;;
  23. serve)
  24. cmd+="__serve"
  25. ;;
  26. *)
  27. ;;
  28. esac
  29. done
  30. case "${cmd}" in
  31. gutenberg)
  32. opts=" -h -V -c --help --version --config init build serve help"
  33. if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
  34. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  35. return 0
  36. fi
  37. case "${prev}" in
  38. --config)
  39. COMPREPLY=($(compgen -f ${cur}))
  40. return 0
  41. ;;
  42. -c)
  43. COMPREPLY=($(compgen -f ${cur}))
  44. return 0
  45. ;;
  46. *)
  47. COMPREPLY=()
  48. ;;
  49. esac
  50. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  51. return 0
  52. ;;
  53. gutenberg__build)
  54. opts=" -h -V -u -o --help --version --base-url --output-dir "
  55. if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
  56. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  57. return 0
  58. fi
  59. case "${prev}" in
  60. --base-url)
  61. COMPREPLY=($(compgen -f ${cur}))
  62. return 0
  63. ;;
  64. -u)
  65. COMPREPLY=($(compgen -f ${cur}))
  66. return 0
  67. ;;
  68. --output-dir)
  69. COMPREPLY=($(compgen -f ${cur}))
  70. return 0
  71. ;;
  72. -o)
  73. COMPREPLY=($(compgen -f ${cur}))
  74. return 0
  75. ;;
  76. *)
  77. COMPREPLY=()
  78. ;;
  79. esac
  80. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  81. return 0
  82. ;;
  83. gutenberg__help)
  84. opts=" -h -V --help --version "
  85. if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
  86. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  87. return 0
  88. fi
  89. case "${prev}" in
  90. *)
  91. COMPREPLY=()
  92. ;;
  93. esac
  94. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  95. return 0
  96. ;;
  97. gutenberg__init)
  98. opts=" -h -V --help --version <name> "
  99. if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
  100. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  101. return 0
  102. fi
  103. case "${prev}" in
  104. *)
  105. COMPREPLY=()
  106. ;;
  107. esac
  108. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  109. return 0
  110. ;;
  111. gutenberg__serve)
  112. opts=" -h -V -i -p -o -u --help --version --interface --port --output-dir --base-url "
  113. if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
  114. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  115. return 0
  116. fi
  117. case "${prev}" in
  118. --interface)
  119. COMPREPLY=($(compgen -f ${cur}))
  120. return 0
  121. ;;
  122. -i)
  123. COMPREPLY=($(compgen -f ${cur}))
  124. return 0
  125. ;;
  126. --port)
  127. COMPREPLY=($(compgen -f ${cur}))
  128. return 0
  129. ;;
  130. -p)
  131. COMPREPLY=($(compgen -f ${cur}))
  132. return 0
  133. ;;
  134. --output-dir)
  135. COMPREPLY=($(compgen -f ${cur}))
  136. return 0
  137. ;;
  138. -o)
  139. COMPREPLY=($(compgen -f ${cur}))
  140. return 0
  141. ;;
  142. --base-url)
  143. COMPREPLY=($(compgen -f ${cur}))
  144. return 0
  145. ;;
  146. -u)
  147. COMPREPLY=($(compgen -f ${cur}))
  148. return 0
  149. ;;
  150. *)
  151. COMPREPLY=()
  152. ;;
  153. esac
  154. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  155. return 0
  156. ;;
  157. esac
  158. }
  159. complete -F _gutenberg -o bashdefault -o default gutenberg