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.

144 lines
4.2KB

  1. #compdef zola
  2. autoload -U is-at-least
  3. _zola() {
  4. typeset -A opt_args
  5. typeset -a _arguments_options
  6. local ret=1
  7. if is-at-least 5.2; then
  8. _arguments_options=(-s -S -C)
  9. else
  10. _arguments_options=(-s -C)
  11. fi
  12. local context curcontext="$curcontext" state line
  13. _arguments "${_arguments_options[@]}" \
  14. '-c+[Path to a config file other than config.toml]' \
  15. '--config=[Path to a config file other than config.toml]' \
  16. '-h[Prints help information]' \
  17. '--help[Prints help information]' \
  18. '-V[Prints version information]' \
  19. '--version[Prints version information]' \
  20. ":: :_zola_commands" \
  21. "*::: :->zola" \
  22. && ret=0
  23. case $state in
  24. (zola)
  25. words=($line[1] "${words[@]}")
  26. (( CURRENT += 1 ))
  27. curcontext="${curcontext%:*:*}:zola-command-$line[1]:"
  28. case $line[1] in
  29. (init)
  30. _arguments "${_arguments_options[@]}" \
  31. '-h[Prints help information]' \
  32. '--help[Prints help information]' \
  33. '-V[Prints version information]' \
  34. '--version[Prints version information]' \
  35. '::name -- Name of the project. Will create a new directory with that name in the current directory:_files' \
  36. && ret=0
  37. ;;
  38. (build)
  39. _arguments "${_arguments_options[@]}" \
  40. '-u+[Force the base URL to be that value (default to the one in config.toml)]' \
  41. '--base-url=[Force the base URL to be that value (default to the one in config.toml)]' \
  42. '-o+[Outputs the generated site in the given path]' \
  43. '--output-dir=[Outputs the generated site in the given path]' \
  44. '--drafts[Include drafts when loading the site]' \
  45. '-h[Prints help information]' \
  46. '--help[Prints help information]' \
  47. '-V[Prints version information]' \
  48. '--version[Prints version information]' \
  49. && ret=0
  50. ;;
  51. (serve)
  52. _arguments "${_arguments_options[@]}" \
  53. '-i+[Interface to bind on]' \
  54. '--interface=[Interface to bind on]' \
  55. '-p+[Which port to use]' \
  56. '--port=[Which port to use]' \
  57. '-o+[Outputs the generated site in the given path]' \
  58. '--output-dir=[Outputs the generated site in the given path]' \
  59. '-u+[Changes the base_url]' \
  60. '--base-url=[Changes the base_url]' \
  61. '--watch-only[Do not start a server, just re-build project on changes]' \
  62. '--drafts[Include drafts when loading the site]' \
  63. '-O[Open site in the default browser]' \
  64. '--open[Open site in the default browser]' \
  65. '-h[Prints help information]' \
  66. '--help[Prints help information]' \
  67. '-V[Prints version information]' \
  68. '--version[Prints version information]' \
  69. && ret=0
  70. ;;
  71. (check)
  72. _arguments "${_arguments_options[@]}" \
  73. '--drafts[Include drafts when loading the site]' \
  74. '-h[Prints help information]' \
  75. '--help[Prints help information]' \
  76. '-V[Prints version information]' \
  77. '--version[Prints version information]' \
  78. && ret=0
  79. ;;
  80. (help)
  81. _arguments "${_arguments_options[@]}" \
  82. '-h[Prints help information]' \
  83. '--help[Prints help information]' \
  84. '-V[Prints version information]' \
  85. '--version[Prints version information]' \
  86. && ret=0
  87. ;;
  88. esac
  89. ;;
  90. esac
  91. }
  92. (( $+functions[_zola_commands] )) ||
  93. _zola_commands() {
  94. local commands; commands=(
  95. "init:Create a new Zola project" \
  96. "build:Deletes the output directory if there is one and builds the site" \
  97. "serve:Serve the site. Rebuild and reload on change automatically" \
  98. "check:Try building the project without rendering it. Checks links" \
  99. "help:Prints this message or the help of the given subcommand(s)" \
  100. )
  101. _describe -t commands 'zola commands' commands "$@"
  102. }
  103. (( $+functions[_zola__build_commands] )) ||
  104. _zola__build_commands() {
  105. local commands; commands=(
  106. )
  107. _describe -t commands 'zola build commands' commands "$@"
  108. }
  109. (( $+functions[_zola__check_commands] )) ||
  110. _zola__check_commands() {
  111. local commands; commands=(
  112. )
  113. _describe -t commands 'zola check commands' commands "$@"
  114. }
  115. (( $+functions[_zola__help_commands] )) ||
  116. _zola__help_commands() {
  117. local commands; commands=(
  118. )
  119. _describe -t commands 'zola help commands' commands "$@"
  120. }
  121. (( $+functions[_zola__init_commands] )) ||
  122. _zola__init_commands() {
  123. local commands; commands=(
  124. )
  125. _describe -t commands 'zola init commands' commands "$@"
  126. }
  127. (( $+functions[_zola__serve_commands] )) ||
  128. _zola__serve_commands() {
  129. local commands; commands=(
  130. )
  131. _describe -t commands 'zola serve commands' commands "$@"
  132. }
  133. _zola "$@"