|
| 1 | +#compdef jekyll |
| 2 | +# ------------------------------------------------------------------------------ |
| 3 | +# Description |
| 4 | +# ----------- |
| 5 | +# |
| 6 | +# Completion script for jekyll(http://jekyllrb.com) |
| 7 | +# |
| 8 | +# ------------------------------------------------------------------------------ |
| 9 | +# Authors |
| 10 | +# ------- |
| 11 | +# |
| 12 | +# * farseer90718 (https://github.com/farseer90718) |
| 13 | +# |
| 14 | +# ------------------------------------------------------------------------------ |
| 15 | + |
| 16 | +local ret=1 state |
| 17 | + |
| 18 | +local -a common_ops |
| 19 | +common_ops=( |
| 20 | + {-v,--version}"[Display version information]" |
| 21 | + {-h,--help}"[Display help documentation]" |
| 22 | + {-p,--plugins}"[Plugins directory (defautls to ./_plugins)]: :_directories" |
| 23 | + {-s,--source}"[Source directory (defaults to ./)]: :_directories" |
| 24 | + {-d,--destination}"[Destination directory (defautls to ./_site)]: :_directories" |
| 25 | + "--layouts=[Layouts directory (defaults to ./_layouts)]: :_directories" |
| 26 | + "--safe=[Safe mode (defaults to false)]" |
| 27 | +) |
| 28 | + |
| 29 | +typeset -A opt_args |
| 30 | +_arguments \ |
| 31 | + ':subcommand:->subcommand' \ |
| 32 | + $common_ops \ |
| 33 | + '*::options:->options' && ret=0 |
| 34 | + |
| 35 | +case $state in |
| 36 | + subcommand) |
| 37 | + local -a subcommands |
| 38 | + subcommands=( |
| 39 | + "build:Build your site" |
| 40 | + "docs:Launch local server with docs for jekyll" |
| 41 | + "doctor:Search site and print specific deprecation warnings" |
| 42 | + "help:Dislplay global or [command] help documentation" |
| 43 | + "import:Import your old blog to Jekyll" |
| 44 | + "new:Creates a new Jekyll site scaffold in PATH" |
| 45 | + "serve:Serve your stie locally" |
| 46 | + ) |
| 47 | + |
| 48 | + _describe -t subcommands 'jekyll subcommand' subcommands && ret=0 |
| 49 | + ;; |
| 50 | + |
| 51 | + options) |
| 52 | + local -a args |
| 53 | + args=( |
| 54 | + $common_ops |
| 55 | + ) |
| 56 | + |
| 57 | + local -a config |
| 58 | + config=( |
| 59 | + "--config[Custome configuration file]: :_files" |
| 60 | + ) |
| 61 | + local -a help |
| 62 | + help=( |
| 63 | + {-h,--help}"[Display help information]" |
| 64 | + ) |
| 65 | + local -a build |
| 66 | + build=( |
| 67 | + {-w,--watch}"[Watch for changes and rebuild]" |
| 68 | + "--limit_posts[Limits the number of posts to parse and publish]" |
| 69 | + "--future[Publishes posts with a future date]" |
| 70 | + "--lsi[Use LSI for improved related posts]" |
| 71 | + "--drafts[Render posts in the _drafts folder]" |
| 72 | + ) |
| 73 | + |
| 74 | + case $words[1] in |
| 75 | + help) |
| 76 | + args=() |
| 77 | + compadd "$@" build docs doctor help import new serve |
| 78 | + ;; |
| 79 | + |
| 80 | + build) |
| 81 | + args+=( |
| 82 | + $build |
| 83 | + $config |
| 84 | + ) |
| 85 | + ;; |
| 86 | + |
| 87 | + docs) |
| 88 | + args=( |
| 89 | + {-p,--port}"[Port to listen on]: :_ports" |
| 90 | + {-u,--host}"[Host to bind to]: :_hosts" |
| 91 | + $help |
| 92 | + ) |
| 93 | + ;; |
| 94 | + |
| 95 | + doctor) |
| 96 | + args+=( |
| 97 | + $config |
| 98 | + ) |
| 99 | + ;; |
| 100 | + |
| 101 | + import) |
| 102 | + args=( |
| 103 | + "--source[Source file or URL to migrate from]:url" |
| 104 | + "--file[File to migrate from]: :_files" |
| 105 | + "--dbname[Database name to migrate from]:database" |
| 106 | + "--user[Username to use when migrating]:user" |
| 107 | + "--pass[Password to use when migrating]:password" |
| 108 | + "--host[Host address to use when migrating]:url" |
| 109 | + $help |
| 110 | + ) |
| 111 | + ;; |
| 112 | + |
| 113 | + new) |
| 114 | + args=( |
| 115 | + ": :_directories" |
| 116 | + "--force[Force creation even if PATH already exists]" |
| 117 | + "--blank[Creates scaffolding but with empty files]" |
| 118 | + $help |
| 119 | + ) |
| 120 | + ;; |
| 121 | + |
| 122 | + serve) |
| 123 | + args+=( |
| 124 | + $build |
| 125 | + $config |
| 126 | + {-P,--port}"[Port to listen on]: :_posts" |
| 127 | + {-H,--host}"[Host to bind to]: :_hosts" |
| 128 | + {-b,--baseurl}"[Base URL]:url" |
| 129 | + ) |
| 130 | + |
| 131 | + esac |
| 132 | + |
| 133 | + _arguments $args && ret=0 |
| 134 | + ;; |
| 135 | +esac |
| 136 | + |
| 137 | +return ret |
| 138 | + |
| 139 | +# Local Variables: |
| 140 | +# mode: Shell-Script |
| 141 | +# sh-indentation: 2 |
| 142 | +# indent-tabs-mode: nil |
| 143 | +# sh-basic-offset: 2 |
| 144 | +# End: |
| 145 | +# vim: ft=zsh sw=2 ts=2 et |
0 commit comments