summarylogtreecommitdiffstats
path: root/_camisole
blob: 378fb6aa0f76ce1a993f689d61da5ac8c24fd249 (plain)
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
#compdef camisole

_camisole () {
  local curcontext=$curcontext state line
  local -a help_opts
  help_opts=('(- :)'{-h,--help}'[display help]')
  typeset -a opts
  typeset -A opt_args

  opts=($help_opts \
    '*'{-m,--module=}'[extra module to load]:module:_python_modules' \
    '(-l --logging)'{-l,--logging=}'[logging level]:logging level:(critical fatal error warn warning info debug notset)'
    )

  _arguments -s -S -C $opts \
    '(-): :->command' \
    '(-)*:: :->opt-or-arg' && return

  case $state in
    (command)
      local -a commands
      commands=(
        'serve:start HTTP server' \
        'languages:check for working/failing languages')
      _describe -t commands command commands && ret=0
    ;;
    (opt-or-arg)
      curcontext=${curcontext%:*}-$line[1]:
      case $line[1] in
        (serve)
          opts=(
            '(-h --host)'{-h+,--host=}'[server host]:host' \
            '(-p --port)'{-p+,--port=}'[server port]:port'
            )
        ;;
        (languages)
          opts=($help_opts \
            '(-vv)-v[verbose mode]' \
            '(-v)-vv[very verbose mode]'
            )
        ;;
      esac
    ;;
  esac
  _arguments -s -S $opts && ret=0
  return ret
}

_camisole "$@"