aboutsummaryrefslogtreecommitdiffstats
path: root/src/_showoff
blob: 1b124d70934848080375d47d596883e4c5c2dfe2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#compdef showoff
# ------------------------------------------------------------------------------
# Copyright (c) 2016 Github zsh-users - https://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of the zsh-users nor the
#       names of its contributors may be used to endorse or promote products
#       derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
#  Completion script for Showoff 0.20.3 (https://github.com/puppetlabs/showoff).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
#  * Bruno Michel (https://github.com/nono)
#  * Shohei Yoshida (https://github.com/nono)
#
# ------------------------------------------------------------------------------

_showoff_subcommands() {
  local -a commands=(
    "add:Add a new slide at the end in a given dir"
    "new:Add a new slide at the end in a given dir"
    "create:Create new showoff presentation"
    "init:Create new showoff presentation"
    "github:Puts your showoff presentation into a gh-pages branch"
    "help:Shows a list of commands or help for one command"
    "heroku:Setup your presentation to serve on Heroku"
    "info:Display information about a Showoff presentation"
    "pdf:Generate PDF version of presentation"
    "serve:Serves the showoff presentation in the specified (or current) directory"
    "skeleton:Build a showoff presentation from a showoff.json outline"
    "static:Generate static version of presentation"
    "validate:Validate the consistency of your presentation"
  )

  _describe -t commands 'showoff command' commands
}

_showoff_help() {
  local -a commands=(${(@f)"$(showoff help -c 2>/dev/null)"})
  _values 'commands' $commands
}

_showoff() {
  local curcontext="$curcontext" state line ret=1

  _arguments -C \
    '--debug[Show application backtraces on crash]' \
    '--dev[Use the next-gen development version of Showoff]' \
    '(- *)--help[Show help message]' \
    '(- *)--version[Display the program version]' \
    '1: :_showoff_subcommands' \
    '*:: :->args' \
      && ret=0

  case $state in
    (args)
      case $line[1] in
        (add|new)
          _arguments \
            '(-d --dir)'{-d,--dir}='[Slide dir (where to put a new slide file)]:directory:_files -/' \
            '(-n --name)'{-n,--name}='[Slide name (name of the new slide file)]:basename' \
            {-s,--source}='[Include code from the given file as the slide body]:file:_files' \
            '(-t --style --type)'{-t,--style,--type}='[Slide Type/Style (default: title)]:style' \
            '(-u --nonumber)'{-u,--nonumber}"[Don't number the slide, use the given name verbatim]" \
            '1:title' && ret=0
          ;;
        (create|init)
          _arguments \
            '(-d --slidedir)'{-d,--slidedir}='[Sample slide directory name (default: one)]:arg' \
            '(-n --nosamples)'{-n,--nosamples}="[Don't create sample slides]" \
            '1:dir_name' && ret=0
          ;;
        (help)
          _arguments \
            '-c[List commands one per line, to assist with shell completion]' \
            '1: :_showoff_help' && ret=0
          ;;
        (heroku)
          _arguments \
            '(-f --force)'{-f,--force}'[force overwrite of existing Gemfile, .gems and config.ru files if they exist]' \
            '(-p --password)'{-p,--password}='[add password protection to your heroku site(default: none)]' \
            '1:heroku_name' && ret=0
          ;;
        (info)
          _arguments \
            '(-f --file)'{-f,--file}='[alternate json filename]: :_files -g "*.json"' \
            '(-j --json)'{-j,--json}'[render output as json]' \
            && ret=0
          ;;
        (pdf|static)
          _arguments \
            '(-f --file --pres_file)'{-f,--file,--pres_file}='[JSON file used to describe presentation(default: showoff.json)]: :_files -g "*.json"' \
            '(-l --lang --language --locale)'{-l,--lang,--language,--locale}'[Language code to generate(default: none)]' \
            '1:name' \
            && ret=0
          ;;
        (serve)
          _arguments \
            '(-S --standalone)'{-S,--standalone}'[Run in standalone mode with no audience interaction]' \
            '(-f --file --pres_file)'{-f,--file,--pres_file}='[JSON file used to describe presentation(default: showoff.json)]: :_files -g "*.json"' \
            '--git_branch=[Branch of git repository to use(default: none)]:branch' \
            '--git_path=[Path of the presentation within the git repository(default: none)]:path' \
            '(-h --host)'{-h,--host}='[Host or IP to run on(default: 0.0.0.0)]' \
            '--nocache[Disable content caching]'\
            '--nosleep[Prevent the computer from sleeping during your presentation]' \
            '(-p --port)'{-p,--port}='[Port on which to run(default: 9090)]' \
            '(-r --review)'{-r,--review}'[Enable code review]'\
            '(-s --ssl)'{-s,--ssl}'[Run via HTTPS]' \
            '--ssl_certificate=[Path to SSL certificate]: :_files' \
            '--ssl_private_key=[Path to SSL private key]: :_files' \
            '(-u --url --git_url)'{-u,--url,--git_url}='[GIT URL to a repository containing the presentation]:url' \
            '(-v --verbose)'{-v,--verbose}'[Show verbose messaging]' \
            '(-x --execute --executecode)'{-x,--execute,--executecode}'[Enable remote code execution]' \
            '1: :_files -/' && ret=0
          ;;
        (skeleton|validate)
          _arguments \
            '(-f --file)'{-f,--file}'=[alternate json filename(default: none)]: :_files -g "*.json"' \
            && ret=0
          ;;
        *)
          (( ret )) && _message 'no more arguments'
          ;;
      esac
      ;;
  esac

  return ret
}

_showoff "$@"

# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et