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.

123 lines
3.5KB

  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. (help)
  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. esac
  76. ;;
  77. esac
  78. }
  79. (( $+functions[_zola_commands] )) ||
  80. _zola_commands() {
  81. local commands; commands=(
  82. "init:Create a new Zola project" \
  83. "build:Builds the site" \
  84. "serve:Serve the site. Rebuild and reload on change automatically" \
  85. "help:Prints this message or the help of the given subcommand(s)" \
  86. )
  87. _describe -t commands 'zola commands' commands "$@"
  88. }
  89. (( $+functions[_zola__build_commands] )) ||
  90. _zola__build_commands() {
  91. local commands; commands=(
  92. )
  93. _describe -t commands 'zola build commands' commands "$@"
  94. }
  95. (( $+functions[_zola__help_commands] )) ||
  96. _zola__help_commands() {
  97. local commands; commands=(
  98. )
  99. _describe -t commands 'zola help commands' commands "$@"
  100. }
  101. (( $+functions[_zola__init_commands] )) ||
  102. _zola__init_commands() {
  103. local commands; commands=(
  104. )
  105. _describe -t commands 'zola init commands' commands "$@"
  106. }
  107. (( $+functions[_zola__serve_commands] )) ||
  108. _zola__serve_commands() {
  109. local commands; commands=(
  110. )
  111. _describe -t commands 'zola serve commands' commands "$@"
  112. }
  113. _zola "$@"