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
|
# Sup Bash completion
#
# * Complete options for all Sup commands.
# * Disable completion for next option when current option takes an argument.
# * Complete sources, directories, and files, where applicable.
_sup_cmds() {
local cur prev opts sources
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
sources="$(sed -n '/uri:/ {s/.*uri:\s*//p}' $HOME/.sup/sources.yaml)"
case "${1##/*}" in
sup-add)
opts="--archive -a --unusual -u --sync-back --no-sync-back -s
--labels -l --force-new -f --force-account -o --version -v
--help -h mbox: maildir:"
case $prev in
--labels|-l|--force-account|-o)
COMPREPLY=()
return 0
;;
esac
;;
sup-config|sup-dump)
opts="--version -v --help -h"
;;
sup-import-dump)
opts="--verbose -v --ignore-missing -i --warn-missing -w
--abort-missing -a --atomic -t --dry-run -n --version --help
-h"
;;
sup-mail)
opts="--list-hooks -l --no-threads -n --no-initial-poll -o --search
-s --compose -c --subject -j --version -v --help -h"
case $prev in
--search|-s|--compose|-c|--subject|-j)
COMPREPLY=()
return 0
;;
esac
;;
sup-recover-sources)
opts="--unusual --archive --scan-num --help -h $sources"
case $prev in
--scan-num)
COMPREPLY=()
return 0
;;
esac
;;
sup-sync)
opts="--asis --restore --discard --archive -x --read -r
--extra-labels --verbose -v --optimize -o --all-sources
--dry-run -n --version --help -h ${sources}"
case $prev in
--restore|--extra-labels)
COMPREPLY=()
return 0
;;
esac
;;
sup-sync-back-maildir)
maildir_sources="$(echo $sources | tr ' ' '\n' | grep maildir)"
opts="--no-confirm -n --no-merge -m --list-sources -l
--unusual-sources-too -u --version -v --help -h
$maildir_sources"
;;
sup-tweak-labels)
opts="--add -a --remove -r --query -q --verbose -v --very-verbose
-e --all-sources --dry-run -n --no-sync-back -o --version
--help -h $sources"
case $prev in
--add|-a|--remove|-r|--query|-q)
COMPREPLY=()
return 0
;;
esac
;;
esac
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
return 0
}
complete -F _sup_cmds sup-mail \
sup-add \
sup-config \
sup-dump \
sup-recover-sources \
sup-sync \
sup-sync-back-maildir \
sup-tweak-labels
complete -F _sup_cmds -o filenames -o plusdirs sup-import-dump
|