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.

zola.bash 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. _zola() {
  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. zola)
  12. cmd="zola"
  13. ;;
  14. build)
  15. cmd+="__build"
  16. ;;
  17. check)
  18. cmd+="__check"
  19. ;;
  20. help)
  21. cmd+="__help"
  22. ;;
  23. init)
  24. cmd+="__init"
  25. ;;
  26. serve)
  27. cmd+="__serve"
  28. ;;
  29. *)
  30. ;;
  31. esac
  32. done
  33. case "${cmd}" in
  34. zola)
  35. opts=" -h -V -c --help --version --config init build serve check help"
  36. if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
  37. COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
  38. return 0
  39. fi
  40. case "${prev}" in
  41. --config)
  42. COMPREPLY=($(compgen -f "${cur}"))
  43. return 0
  44. ;;
  45. -c)
  46. COMPREPLY=($(compgen -f "${cur}"))
  47. return 0
  48. ;;
  49. *)
  50. COMPREPLY=()
  51. ;;
  52. esac
  53. COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
  54. return 0
  55. ;;
  56. zola__build)
  57. opts=" -h -V -u -o --drafts --help --version --base-url --output-dir "
  58. if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
  59. COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
  60. return 0
  61. fi
  62. case "${prev}" in
  63. --base-url)
  64. COMPREPLY=($(compgen -f "${cur}"))
  65. return 0
  66. ;;
  67. -u)
  68. COMPREPLY=($(compgen -f "${cur}"))
  69. return 0
  70. ;;
  71. --output-dir)
  72. COMPREPLY=($(compgen -f "${cur}"))
  73. return 0
  74. ;;
  75. -o)
  76. COMPREPLY=($(compgen -f "${cur}"))
  77. return 0
  78. ;;
  79. *)
  80. COMPREPLY=()
  81. ;;
  82. esac
  83. COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
  84. return 0
  85. ;;
  86. zola__check)
  87. opts=" -h -V --drafts --help --version "
  88. if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
  89. COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
  90. return 0
  91. fi
  92. case "${prev}" in
  93. *)
  94. COMPREPLY=()
  95. ;;
  96. esac
  97. COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
  98. return 0
  99. ;;
  100. zola__help)
  101. opts=" -h -V --help --version "
  102. if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
  103. COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
  104. return 0
  105. fi
  106. case "${prev}" in
  107. *)
  108. COMPREPLY=()
  109. ;;
  110. esac
  111. COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
  112. return 0
  113. ;;
  114. zola__init)
  115. opts=" -h -V --help --version <name> "
  116. if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
  117. COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
  118. return 0
  119. fi
  120. case "${prev}" in
  121. *)
  122. COMPREPLY=()
  123. ;;
  124. esac
  125. COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
  126. return 0
  127. ;;
  128. zola__serve)
  129. opts=" -O -h -V -i -p -o -u --watch-only --drafts --open --help --version --interface --port --output-dir --base-url "
  130. if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
  131. COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
  132. return 0
  133. fi
  134. case "${prev}" in
  135. --interface)
  136. COMPREPLY=($(compgen -f "${cur}"))
  137. return 0
  138. ;;
  139. -i)
  140. COMPREPLY=($(compgen -f "${cur}"))
  141. return 0
  142. ;;
  143. --port)
  144. COMPREPLY=($(compgen -f "${cur}"))
  145. return 0
  146. ;;
  147. -p)
  148. COMPREPLY=($(compgen -f "${cur}"))
  149. return 0
  150. ;;
  151. --output-dir)
  152. COMPREPLY=($(compgen -f "${cur}"))
  153. return 0
  154. ;;
  155. -o)
  156. COMPREPLY=($(compgen -f "${cur}"))
  157. return 0
  158. ;;
  159. --base-url)
  160. COMPREPLY=($(compgen -f "${cur}"))
  161. return 0
  162. ;;
  163. -u)
  164. COMPREPLY=($(compgen -f "${cur}"))
  165. return 0
  166. ;;
  167. *)
  168. COMPREPLY=()
  169. ;;
  170. esac
  171. COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
  172. return 0
  173. ;;
  174. esac
  175. }
  176. complete -F _zola -o bashdefault -o default zola