public
Description: Bits and bobs of zsh hacking.
Homepage:
Clone URL: git://github.com/nickstenning/zsh.git
zsh / completions / _gibak
100755 99 lines (85 sloc) 2.795 kb
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
#compdef gibak
 
local state context expl
typeset -A opt_args
local cmd cmds
 
local time_spec_msg="time spec, e.g. \"5 days ago\", or \"2 days 2 hours 3 seconds ago\", or \"1979-02-26 18:30:00\""
 
_arguments -s \
  '*::command:->command' && ret=0
 
while [[ -n "$state" ]]; do
  tmp="$state"
  state=
  case "$tmp" in
  command)
    if (( CURRENT == 1 )); then
      state=gibak_commands
    else
      cmd="$words[1]"
      curcontext="${curcontext%:*:*}:gibak-${cmd}:"
      case "$cmd" in
      
      eat)
        _wanted files expl 'file/directory' _files
        ;;
 
      show)
        if (( CURRENT == 2 )); then
          _wanted files expl 'file' _files
        elif (( CURRENT == 3 )); then
          _wanted value expl ${time_spec_msg} compadd -P'as of' ''
        elif (( CURRENT == 4 )); then
          _wanted value expl ${time_spec_msg} compadd -P'of' ''
        else
          _message ${time_spec_msg}
        fi
        ;;
 
      archive-to)
        if (( CURRENT == 2 )); then
          _wanted files expl 'file' _files
        else
          _nothing
        fi
        ;;
 
      extract-archive-to)
        if (( CURRENT == 2 )); then
          _wanted directory expl 'directory' _files -/
        else
          _nothing
        fi
        ;;
        
      ls-stored-files)
        if (( CURRENT == 2 )); then
          _wanted value expl ${time_spec_msg} compadd -P'as of' ''
        elif (( CURRENT == 3 )); then
          _wanted value expl ${time_spec_msg} compadd -P'of' ''
        else
          _message ${time_spec_msg}
        fi
        ;;
        
      rm-older-than)
        _message ${time_spec_msg}
        ;;
        
      init|help|commit|ls-changed-files|ls-new-files|ls-ignored-files|ls-newly-ignored-files|rm-all)
        _nothing
        ;;
 
      esac
    fi
  ;;
 
  gibak_commands)
    cmds=(
      'help:show help text'
      'init:set up the gibak git repository in ${HOME}/.git'
      'commit:commit changes to the gibak repository'
      'eat:add changes in a file/directory to the gibak repository, then remove'
      'show:show the contents of a file as of some time in the past'
      'ls-changed-files:show files that have changed since last commit'
      'ls-new-files:show new files since last commit'
      'ls-ignored-files:show files that gibak is ignoring'
      'ls-newly-ignored-files:show files that gibak will now ignore'
      'ls-stored-files:show files in the gibak repository'
      'archive-to:write a GPGed tar file of the repository contents'
      'extract-archive-to:extract an archive of the repository to a directory'
      'rm-all:reinitialize (i.e. delete ALL of the repository contents)'
      'rm-older-than:remove files older than a particular time'
    )
    _describe 'gibak command' cmds --
    ;;
 
  esac
done