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.

139 lines
4.0KB

  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. '-h[Prints help information]' \
  45. '--help[Prints help information]' \
  46. '-V[Prints version information]' \
  47. '--version[Prints version information]' \
  48. && ret=0
  49. ;;
  50. (serve)
  51. _arguments "${_arguments_options[@]}" \
  52. '-i+[Interface to bind on]' \
  53. '--interface=[Interface to bind on]' \
  54. '-p+[Which port to use]' \
  55. '--port=[Which port to use]' \
  56. '-o+[Outputs the generated site in the given path]' \
  57. '--output-dir=[Outputs the generated site in the given path]' \
  58. '-u+[Changes the base_url]' \
  59. '--base-url=[Changes the base_url]' \
  60. '--watch-only[Do not start a server, just re-build project on changes]' \
  61. '-h[Prints help information]' \
  62. '--help[Prints help information]' \
  63. '-V[Prints version information]' \
  64. '--version[Prints version information]' \
  65. && ret=0
  66. ;;
  67. (check)
  68. _arguments "${_arguments_options[@]}" \
  69. '-h[Prints help information]' \
  70. '--help[Prints help information]' \
  71. '-V[Prints version information]' \
  72. '--version[Prints version information]' \
  73. && ret=0
  74. ;;
  75. (help)
  76. _arguments "${_arguments_options[@]}" \
  77. '-h[Prints help information]' \
  78. '--help[Prints help information]' \
  79. '-V[Prints version information]' \
  80. '--version[Prints version information]' \
  81. && ret=0
  82. ;;
  83. esac
  84. ;;
  85. esac
  86. }
  87. (( $+functions[_zola_commands] )) ||
  88. _zola_commands() {
  89. local commands; commands=(
  90. "init:Create a new Zola project" \
  91. "build:Deletes the output directory if there is one and builds the site" \
  92. "serve:Serve the site. Rebuild and reload on change automatically" \
  93. "check:Try building the project without rendering it. Checks links" \
  94. "help:Prints this message or the help of the given subcommand(s)" \
  95. )
  96. _describe -t commands 'zola commands' commands "$@"
  97. }
  98. (( $+functions[_zola__build_commands] )) ||
  99. _zola__build_commands() {
  100. local commands; commands=(
  101. )
  102. _describe -t commands 'zola build commands' commands "$@"
  103. }
  104. (( $+functions[_zola__check_commands] )) ||
  105. _zola__check_commands() {
  106. local commands; commands=(
  107. )
  108. _describe -t commands 'zola check commands' commands "$@"
  109. }
  110. (( $+functions[_zola__help_commands] )) ||
  111. _zola__help_commands() {
  112. local commands; commands=(
  113. )
  114. _describe -t commands 'zola help commands' commands "$@"
  115. }
  116. (( $+functions[_zola__init_commands] )) ||
  117. _zola__init_commands() {
  118. local commands; commands=(
  119. )
  120. _describe -t commands 'zola init commands' commands "$@"
  121. }
  122. (( $+functions[_zola__serve_commands] )) ||
  123. _zola__serve_commands() {
  124. local commands; commands=(
  125. )
  126. _describe -t commands 'zola serve commands' commands "$@"
  127. }
  128. _zola "$@"