nickstenning / zsh
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
zsh / completions / _gibak
| 1d38f0ae » | nickstenning | 2008-04-04 | 1 | #compdef gibak | |
| 2 | |||||
| 3 | local state context expl | ||||
| 4 | typeset -A opt_args | ||||
| 5 | local cmd cmds | ||||
| 6 | |||||
| 7 | 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\"" | ||||
| 8 | |||||
| 9 | _arguments -s \ | ||||
| 10 | '*::command:->command' && ret=0 | ||||
| 11 | |||||
| 12 | while [[ -n "$state" ]]; do | ||||
| 13 | tmp="$state" | ||||
| 14 | state= | ||||
| 15 | case "$tmp" in | ||||
| 16 | command) | ||||
| 17 | if (( CURRENT == 1 )); then | ||||
| 18 | state=gibak_commands | ||||
| 19 | else | ||||
| 20 | cmd="$words[1]" | ||||
| 21 | curcontext="${curcontext%:*:*}:gibak-${cmd}:" | ||||
| 22 | case "$cmd" in | ||||
| 23 | |||||
| 24 | eat) | ||||
| 25 | _wanted files expl 'file/directory' _files | ||||
| 26 | ;; | ||||
| 27 | |||||
| 28 | show) | ||||
| 29 | if (( CURRENT == 2 )); then | ||||
| 30 | _wanted files expl 'file' _files | ||||
| 31 | elif (( CURRENT == 3 )); then | ||||
| 32 | _wanted value expl ${time_spec_msg} compadd -P'as of' '' | ||||
| 33 | elif (( CURRENT == 4 )); then | ||||
| 34 | _wanted value expl ${time_spec_msg} compadd -P'of' '' | ||||
| 35 | else | ||||
| 36 | _message ${time_spec_msg} | ||||
| 37 | fi | ||||
| 38 | ;; | ||||
| 39 | |||||
| 40 | archive-to) | ||||
| 41 | if (( CURRENT == 2 )); then | ||||
| 42 | _wanted files expl 'file' _files | ||||
| 43 | else | ||||
| 44 | _nothing | ||||
| 45 | fi | ||||
| 46 | ;; | ||||
| 47 | |||||
| 48 | extract-archive-to) | ||||
| 49 | if (( CURRENT == 2 )); then | ||||
| 50 | _wanted directory expl 'directory' _files -/ | ||||
| 51 | else | ||||
| 52 | _nothing | ||||
| 53 | fi | ||||
| 54 | ;; | ||||
| 55 | |||||
| 56 | ls-stored-files) | ||||
| 57 | if (( CURRENT == 2 )); then | ||||
| 58 | _wanted value expl ${time_spec_msg} compadd -P'as of' '' | ||||
| 59 | elif (( CURRENT == 3 )); then | ||||
| 60 | _wanted value expl ${time_spec_msg} compadd -P'of' '' | ||||
| 61 | else | ||||
| 62 | _message ${time_spec_msg} | ||||
| 63 | fi | ||||
| 64 | ;; | ||||
| 65 | |||||
| 66 | rm-older-than) | ||||
| 67 | _message ${time_spec_msg} | ||||
| 68 | ;; | ||||
| 69 | |||||
| 70 | init|help|commit|ls-changed-files|ls-new-files|ls-ignored-files|ls-newly-ignored-files|rm-all) | ||||
| 71 | _nothing | ||||
| 72 | ;; | ||||
| 73 | |||||
| 74 | esac | ||||
| 75 | fi | ||||
| 76 | ;; | ||||
| 77 | |||||
| 78 | gibak_commands) | ||||
| 79 | cmds=( | ||||
| 80 | 'help:show help text' | ||||
| 81 | 'init:set up the gibak git repository in ${HOME}/.git' | ||||
| 82 | 'commit:commit changes to the gibak repository' | ||||
| 83 | 'eat:add changes in a file/directory to the gibak repository, then remove' | ||||
| 84 | 'show:show the contents of a file as of some time in the past' | ||||
| 85 | 'ls-changed-files:show files that have changed since last commit' | ||||
| 86 | 'ls-new-files:show new files since last commit' | ||||
| 87 | 'ls-ignored-files:show files that gibak is ignoring' | ||||
| 88 | 'ls-newly-ignored-files:show files that gibak will now ignore' | ||||
| 89 | 'ls-stored-files:show files in the gibak repository' | ||||
| 90 | 'archive-to:write a GPGed tar file of the repository contents' | ||||
| 91 | 'extract-archive-to:extract an archive of the repository to a directory' | ||||
| 92 | 'rm-all:reinitialize (i.e. delete ALL of the repository contents)' | ||||
| 93 | 'rm-older-than:remove files older than a particular time' | ||||
| 94 | ) | ||||
| 95 | _describe 'gibak command' cmds -- | ||||
| 96 | ;; | ||||
| 97 | |||||
| 98 | esac | ||||
| 99 | done | ||||
