summaryrefslogtreecommitdiff
blob: c88ebffe2f7627ba8360a29a58966e7b461897cc (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
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
#compdef bugz
# Copyright 2009 Ingmar Vanhassel <ingmar@exherbo.org>
# vim: set et sw=2 sts=2 ts=2 ft=zsh :

_bugz() {
  local -a _bugz_options _bugz_commands
  local cmd

  _bugz_options=(
    '(-b --base)'{-b,--base}'[bugzilla base URL]:bugzilla url: '
    '(-u --user)'{-u,--user}'[user name (if required)]:user name:_users'
    '(-p --password)'{-p,--password}'[password (if required)]:password: '
    '(-H --httpuser)'{-H,--httpuser}'[basic http auth user name (if required)]:user name:_users'
    '(-P --httppassword)'{-P,--httppassword}'[basic http auth password (if required)]:password: '
    '(-f --forget)'{-f,--forget}'[do not remember authentication]'
    '--columns[number of columns to use when displaying output]:number: '
    '--skip-auth[do not authenticate]'
    '(-q --quiet)'{-q,--quiet}'[do not display status messages]'
  )
  _bugz_commands=(
    'attach:attach file to a bug'
    'attachment:get an attachment from bugzilla'
    'get:get a bug from bugzilla'
    'help:display subcommands'
    'modify:modify a bug (eg. post a comment)'
    'namedcmd:run a stored search'
    'post:post a new bug into bugzilla'
    'search:search for bugs in bugzilla'
  )

  for (( i=1; i <= ${CURRENT}; i++ )); do
    cmd=${_bugz_commands[(r)${words[${i}]}:*]%%:*}
    (( ${#cmd} )) && break
  done

  if (( ${#cmd} )); then
    local curcontext="${curcontext%:*:*}:bugz-${cmd}:"

    while [[ ${words[1]} != ${cmd} ]]; do
      (( CURRENT-- ))
      shift words
    done

    _call_function ret _bugz_cmd_${cmd}
    return ret
  else
    _arguments -s : $_bugz_options
    _describe -t commands 'commands' _bugz_commands
  fi
}

(( ${+functions[_bugz_cmd_attach]} )) ||
_bugz_cmd_attach()
{
  _arguments -s : \
    '(--content_type= -c)'{--content_type=,-c}'[mimetype of the file]:MIME-Type:_mime_types' \
    '(--description= -d)'{--description=,-d}'[a description of the attachment]:description: ' \
    '--help[show help message and exit]'
}

(( ${+functions[_bugz_cmd_attachment]} )) ||
_bugz_cmd_attachment()
{
  _arguments -s : \
    '--help[show help message and exit]' \
    '(--view -v)'{--view,-v}'[print attachment rather than save]'
}


(( ${+functions[_bugz_cmd_get]} )) ||
_bugz_cmd_get()
{
  _arguments -s : \
    '--help[show help message and exit]' \
    '(--no-comments -n)'{--no-comments,-n}'[do not show comments]'
}

(( ${+functions[_bugz_cmd_modify]} )) ||
_bugz_cmd_modify()
{
  _arguments -s : \
    '--add-blocked=[add a bug to the blocked list]:bug: ' \
    '--add-dependson=[add a bug to the depends list]:bug: ' \
    '--add-cc=[add an email to CC list]:email: ' \
    '(--assigned-to= -a)'{--assigned-to=,-a}'[assign bug to someone other than the default assignee]:assignee: ' \
    '(--comment= -c)'{--comment=,-c}'[add comment to bug]:Comment: ' \
    '(--comment-editor -C)'{--comment-editor,-C}'[add comment via default EDITOR]' \
    '(--comment-from= -F)'{--comment-from=,-F}'[add comment from file]:file:_files' \
    '(--duplicate= -d)'{--duplicate=,-d}'[mark bug as a duplicate of bug number]:bug: ' \
    '--fixed[mark bug as RESOLVED, FIXED]' \
    '--help[show help message and exit]' \
    '--invalid[mark bug as RESOLVED, INVALID]' \
    '(--keywords= -k)'{--keywords=,-k}'[list of bugzilla keywords]:keywords: ' \
    '--priority=[set the priority field of the bug]:priority: ' \
    '(--resolution= -r)'{--resolution=,-r}'[set new resolution (only if status = RESOLVED)]' \
    '--remove-cc=[remove an email from the CC list]:email: ' \
    '--remove-dependson=[remove a bug from the depends list]:bug: ' \
    '--remove-blocked=[remove a bug from the blocked list]:bug: ' \
    '(--severity= -S)'{--severity=,-S}'[set severity of the bug]:severity: ' \
    '(--status -s=)'{--status=,-s}'[set new status of bug (eg. RESOLVED)]:status: ' \
    '(--title= -t)'{--title=,-t}'[set title of the bug]:title: ' \
    '(--url= -U)'{--url=,-u}'[set URL field of the bug]:URL: ' \
    '(--whiteboard= -w)'{--whiteboard=,-w}'[set status whiteboard]:status whiteboard: '
}

(( ${+functions[_bugz_cmd_namedcmd]} )) ||
_bugz_cmd_namedcmd()
{
  _arguments -s : \
    '--show-status[show bug status]'
    '--show-url[show bug ID as url]'
}

(( ${+functions[_bugz_cmd_post]} )) ||
_bugz_cmd_post()
{
  _arguments -s : \
    '(--assigned-to= -a)'{--assigned-to=,-a}'[assign bug to someone other than the default assignee]:assignee: ' \
    '--batch[work in batch mode, non-interactively]' \
    '--blocked[add a list of blocker bugs]:blockers: ' \
    '--cc=[add a list of emails to cc list]:email(s): ' \
    '--commenter[email of a commenter]:email: ' \
    '--depends-on[add a list of bug dependencies]:dependencies: ' \
    '(--description= -d)'{--description=,-d}'[description of the bug]:description: ' \
    '(--description-from= -F)'{--description-from=,-f}'[description from contents of a file]:file:_files' \
    '--help[show help message and exit]' \
    '(--keywords= -k)'{--keywords=,-k}'[list of bugzilla keywords]:keywords: ' \
    '(--append-command)--no-append-command[do not append command output]' \
    '(--title= -t)'{--title=,-t}'[title of your bug]:title: ' \
    '(--url= -U)'{--url=,-U}'[URL associated with the bug]:url: ' \
    '--priority[priority of this bug]:priority: ' \
    '--severity[severity of this bug]:severity: '
}

(( ${+functions[_bugz_cmd_search]} )) ||
_bugz_cmd_search()
{
  # TODO --component,--status,--product,--priority can be specified multiple times
  _arguments -s : \
    '(--assigned-to= -a)'{--assigned-to=,-a}'[the email adress the bug is assigned to]:email: ' \
    '--cc=[restrict by CC email address]:email: ' \
    '(--comments -c)'{--comments,-c}'[search comments instead of title]:comment: ' \
    '(--component= -C)'{--component=,-C}'[restrict by component]:component: ' \
    '--help[show help message and exit]' \
    '(--keywords= -k)'{--keywords=,-k}'[bug keywords]:keywords: ' \
    '--severity=[restrict by severity]:severity: ' \
    '--show-status[show bug status]' \
    '--show-url[show bug ID as url]' \
    '(--status= -s)'{--status=,-s}'[bug status]:status: ' \
    '(--order= -o)'{--order=,-o}'[sort by]:order:((number\:"bug number" assignee\:"assignee field" importance\:"importance field" date\:"last changed"))' \
    '--priority=[restrict by priority]:priority: ' \
    '--product=[restrict by product]:product: ' \
    '(--reporter= -r)'{--reporter=,-r}'[email of the reporter]:email: ' \
    '(--whiteboard= -w)'{--whiteboard=,-w}'[status whiteboard]:status whiteboard: '
}

_bugz