#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