about summary refs log tree commit diff
path: root/Completion/Unix/Command/_quilt
blob: 0c51ba5bc4c93a5784ba9ac9e26f9cd7eee021c8 (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
#compdef quilt

local -a tmp
local rc

_arguments \
  '--trace' \
  '--quiltrc:config file:_files' \
  '--version' \
  ':quilt command:(add files import previous setup annotate fold mail push
    snapshot applied fork new refresh top delete graph next remove unapplied
    diff grep patches rename upgrade edit header pop series)' \
  '*::subcmd:->subcmd' && return 0

case "$state" in
  (subcmd)

  case "$words[1]" in
      (applied|delete|files|graph|header|next|previous|refresh|unapplied)
        _wanted -V 'patches' expl 'patch' compadd ${(f)"$(quilt series)"}
        ;;
      (push)
        if (( CURRENT == 2 )); then
          tmp=( ${(f)"$(quilt unapplied 2>&1)"} )
          rc=$?
          if (( rc == 0 )); then
            _wanted -V 'unapplied patches' expl 'patch' compadd "${tmp[@]}"
          else
            _message "No unapplied patches"
          fi
        fi
        ;;
      (pop)
        if (( CURRENT == 2 )); then
          tmp=( ${(f)"$(quilt applied 2>&1)"} )
          rc=$?
          if (( rc == 0 )); then
            _wanted -V 'applied patches' expl 'patch' compadd "${tmp[@]}"
          else
            _message "No applied patches"
          fi
        fi
        ;;
      (*)
        _files
        ;;
  esac
  ;;
esac