Blame | Last modification | View Log | RSS feed
# -*- Mode: sh -*-# URL: https://community.zarafa.com/pg/plugins/project/433/developer/John/bash-completion## 2012-07-02 Retrieved z-b-c# 2012-07-08 Jan Engelhardt# Remove use of @() extglob syntax since it might not be active# after all## bash completion for Zarafa admin command_zarafa__hosts(){local host_completeshost_completes='file:///var/run/zarafa http://localhost:236/zarafa https://localhost:237/zarafa'COMPREPLY=( $( compgen -W "$host_completes" -- ${COMP_WORDS[COMP_CWORD]} ) )return 0}_zarafa__userlist(){# what todo with maybe passed --host ?# what todo with maybe passed -I company, --type ... ?local usersusers=$(zarafa-admin -l | grep -v ^User | grep -v username | grep -v SYSTEM | grep -v -- -- | awk {'print $1'})COMPREPLY=( $( compgen -W "$users" -- ${COMP_WORDS[COMP_CWORD]} ) )return 0}_zarafa__grouplist(){# what todo with maybe passed --host ?# what todo with maybe passed -I company, --type ... ?local groupsgroups=$(zarafa-admin -L | grep -v ^Group | grep -v groupname | grep -v Everyone | grep -v -- -- | awk {'print $1'})COMPREPLY=( $( compgen -W "$groups" -- ${COMP_WORDS[COMP_CWORD]} ) )return 0}_zarafa__companylist(){# what todo with maybe passed --host ?local usersusers=$(zarafa-admin --list-companies | tail -n +4 | awk {'print $1'})COMPREPLY=( $( compgen -W "$users" -- ${COMP_WORDS[COMP_CWORD]} ) )return 0}_zarafa_stats_options(){list='--system --session --users --company --top --user -u --host -h'COMPREPLY=( $( compgen -W "$list" -- ${COMP_WORDS[COMP_CWORD]} ) )}complete -F _zarafa_stats_options zarafa-stats_zarafa_admin_options(){local cur prev short_actions long_actions possiblelistshort_actions='-V -l -L -s -c -u -d -U -P -p -f -e -a -h -g -G -b -B -i -I -n'long_actions='--create-store --remove-store --hook-store --unhook-store --copyto-public --details --type --help --host --sync --qh --qs --qw --qo --udqh --udqs --udqw --udqo --lang --mr-accept --mr-decline-conflict --mr-decline-recurring --add-sendas --del-sendas --list-sendas --list-orphans --create-company --update-company --delete-company --list-companies --add-to-viewlist --del-from-viewlist --list-view --add-to-adminlist --del-from-adminlist --list-admin --set-system-admin --add-userquota-recipient --del-userquota-recipient --list-userquota-recipient --add-companyquota-recipient --del-companyquota-recipient --list-companyquota-recipient --purge-softdelete --purge-deferred --config --enable-feature --disable-feature --clear-cache --user-count'COMPREPLY=()cur=${COMP_WORDS[COMP_CWORD]}prev=${COMP_WORDS[COMP_CWORD-1]}case "$prev" in-h|--host)# host completion is quite senseless, since you need admin rights, and no ssl cert can be used in zarafa-admin_zarafa__hostsreturn 0;;--qo|--qdqo|--mr-*|-a|-n)possiblelist="yes no";;--config)_filedirreturn 0;;--lang|--create-company|-c|-U|-p|-f|-e|-g|--qh|--qs|--qw|--udqh|--udqs|--udqw|--list-admin|--list-userquota-recipient|--list-companyquota-recipient|--purge-softdelete)# opt req, no hintsreturn 0;;-G|-i)_zarafa__grouplistreturn 0;;-I|--list-view|--add-to-viewlist|--del-from-viewlist)_zarafa__companylistreturn 0;;--details|--unhook-store|--create-store|-u|-d|-b|-B|--list-sendas|--add-sendas|--del-sendas|--add-to-adminlist|--del-from-adminlist|--set-system-admin|--add-userquota-recipient|--del-userquota-recipient|--add-companyquota-recipient|--del-companyquota-recipient)_zarafa__userlistreturn 0;;--type)possiblelist="user group company";;--enable-feature|--disable-feature)possiblelist="imap pop3";;esacif [ -z "$possiblelist" ]; thenpossiblelist="$short_actions $long_actions"fiCOMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )return 0}complete -F _zarafa_admin_options $filenames zarafa-admin_zarafa_backup_options(){local cur short_actions long_actions possiblelistshort_actions='-a -p -P -u -h -o -c -s -i -J -N -v'long_actions='--all --user --public --company --company-public --store --skip-junk --skip-public --output --host --config --verbose --help'COMPREPLY=()cur=${COMP_WORDS[COMP_CWORD]}prev=${COMP_WORDS[COMP_CWORD-1]}case "$prev" in-h|--host)_zarafa__hostsreturn 0;;# actually the (.*).zbk.index part ?-u|--user|-f|--from)_zarafa__userlist;;-s|--company|-P|--company-public)_zarafa__companylist;;-i|--restorefile|-c|--config)_filedirreturn 0;;-o|--output)_filedir -dreturn 0;;-i|--store)# opt req, no hintsreturn 0;;# empty parameters, ok with help and read??--all|--public|--skip-junk|--skip-public|--verbose|--help);;-a|-p|-J|-N|-v);;esacif [ -z "$possiblelist" ]; thenpossiblelist="$short_actions $long_actions"fiCOMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )return 0}complete -F _zarafa_backup_options $filenames zarafa-backup_zarafa_restore_options(){local cur short_actions long_actions possiblelistshort_actions='-u -f -h -c -i -r -p -a -b -v'long_actions='--user --public --from --restorefile --recurse --not-before --not-after --host --config --verbose --help'COMPREPLY=()cur=${COMP_WORDS[COMP_CWORD]}prev=${COMP_WORDS[COMP_CWORD-1]}case "$prev" in-h|--host)_zarafa__hostsreturn 0;;# actually the (.*).zbk.index part ?-u|--user|-f|--from)_zarafa__userlist;;-i|--restorefile|-c|--config|-a)_filedirreturn 0;;--not-before|-b)# opt req, no hintsreturn 0;;# empty parameters, ok with help and read??--help|--public|--recurse|--verbose);;-p|-r|-v);;esacif [ -z "$POSSIBLELIST" ]; thenpossiblelist="$short_actions $long_actions"fiCOMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )return 0}complete -F _zarafa_restore_options $filenames zarafa-restore_zarafa_dagent_options(){local cur short_actions long_actions possiblelistshort_actions='-c -j -f -d -h -a -F -P -p -q -s -v -e -n -C -V -r -R -l -N'long_actions='--help --config --junk --file --host --daemonize --listen --folder --public --create --read --do-not-notify --add-imap-data'COMPREPLY=()cur=${COMP_WORDS[COMP_CWORD]}prev=${COMP_WORDS[COMP_CWORD-1]}case "$prev" in-h|--host)_zarafa__hostsreturn 0;;-f|--file|-c|--config|-a)_filedirreturn 0;;-P|--public|-F|--folder|-p)# opt req, no hintsreturn 0;;# empty parameters, ok with help and read??--help|--junk|--daemonize|--listen|--read|--do-not-notify);;-j|-d|-q|-s|-v|-e|-n|-r|-l|-R|-N);;esacif [ -z "$possiblelist" ]; thenpossiblelist="$short_actions $long_actions"fiCOMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )return 0}complete -F _zarafa_dagent_options $filenames zarafa-dagent_zarafa_fsck_options(){local cur short_actions long_actions possiblelistshort_actions='-u -p -P -h -a'long_actions='--help --host --pass --user --calendar --contact --task --all --autofix --autodel --checkonly'COMPREPLY=()cur=${COMP_WORDS[COMP_CWORD]}prev=${COMP_WORDS[COMP_CWORD-1]}case "$prev" in-h|--host)_zarafa__hostsreturn 0;;-u|--user)_zarafa__userlistreturn 0;;-p|--pass)# opt req, no hintsreturn 0;;# empty parameters--calendar|--contact|--task|--all|--autofix|--autodel|--checkonly);;-P|-a);;esacif [ -z "$possiblelist" ]; thenpossiblelist="$short_actions $long_actions"fiCOMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )return 0}complete -F _zarafa_fsck_options zarafa-fsck_zarafa_passwd_options(){local cur short_actions long_actions possiblelistshort_actions='-u -p -h -o -V'long_actions='--help --host'COMPREPLY=()cur=${COMP_WORDS[COMP_CWORD]}prev=${COMP_WORDS[COMP_CWORD-1]}case "$prev" in-h|--host)_zarafa__hostsreturn 0;;-u|-a)_zarafa__userlistreturn 0;;-p|-o|-V)# empty parameters;;esacif [ -z "$possiblelist" ]; thenpossiblelist="$short_actions $long_actions"fiCOMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )return 0}complete -F _zarafa_passwd_options zarafa-passwd_zarafa_archiver_options(){local cur short_actions long_actions possiblelistshort_actions='-u -l -A -w -c'long_actions='--list --archive --local-only --attach-to --detach-from --archive-folder --archive-server --no-folder --write --config --help'COMPREPLY=()cur=${COMP_WORDS[COMP_CWORD]}prev=${COMP_WORDS[COMP_CWORD-1]}case "$prev" in-u|--attach-to|--detach-from)_zarafa__userlistreturn 0;;--archive-server)_zarafa__hostsreturn 0;;-l|-w|-c|--list|--local-only|--archive-folder|--no-folder|--writable|--config|--help)# empty parameters;;esacif [ -z "$possiblelist" ]; thenpossiblelist="$short_actions $long_actions"fiCOMPREPLY=( $( compgen -W "$possiblelist" -- "$cur" ) )return 0}complete -F _zarafa_archiver_options zarafa-archiver