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.

154 lines
4.3KB

  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=" -c -h -V --config --help --version 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. *)
  39. COMPREPLY=()
  40. ;;
  41. esac
  42. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  43. return 0
  44. ;;
  45. gutenberg__build)
  46. opts=" -h -V -u -o --help --version --base-url --output-dir "
  47. if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
  48. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  49. return 0
  50. fi
  51. case "${prev}" in
  52. --base-url)
  53. COMPREPLY=("<base_url>")
  54. return 0
  55. ;;
  56. -u)
  57. COMPREPLY=("<base_url>")
  58. return 0
  59. ;;
  60. --output-dir)
  61. COMPREPLY=("<output_dir>")
  62. return 0
  63. ;;
  64. -o)
  65. COMPREPLY=("<output_dir>")
  66. return 0
  67. ;;
  68. *)
  69. COMPREPLY=()
  70. ;;
  71. esac
  72. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  73. return 0
  74. ;;
  75. gutenberg__help)
  76. opts=" -h -V --help --version "
  77. if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
  78. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  79. return 0
  80. fi
  81. case "${prev}" in
  82. *)
  83. COMPREPLY=()
  84. ;;
  85. esac
  86. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  87. return 0
  88. ;;
  89. gutenberg__init)
  90. opts=" -h -V --help --version <name> "
  91. if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
  92. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  93. return 0
  94. fi
  95. case "${prev}" in
  96. *)
  97. COMPREPLY=()
  98. ;;
  99. esac
  100. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  101. return 0
  102. ;;
  103. gutenberg__serve)
  104. opts=" -h -V -i -p -o --help --version --interface --port --output-dir "
  105. if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
  106. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  107. return 0
  108. fi
  109. case "${prev}" in
  110. --interface)
  111. COMPREPLY=("<interface>")
  112. return 0
  113. ;;
  114. -i)
  115. COMPREPLY=("<interface>")
  116. return 0
  117. ;;
  118. --port)
  119. COMPREPLY=("<port>")
  120. return 0
  121. ;;
  122. -p)
  123. COMPREPLY=("<port>")
  124. return 0
  125. ;;
  126. --output-dir)
  127. COMPREPLY=("<output_dir>")
  128. return 0
  129. ;;
  130. -o)
  131. COMPREPLY=("<output_dir>")
  132. return 0
  133. ;;
  134. *)
  135. COMPREPLY=()
  136. ;;
  137. esac
  138. COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  139. return 0
  140. ;;
  141. esac
  142. }
  143. complete -F _gutenberg -o bashdefault -o default gutenberg