# Michael Schuerig, michael@schuerig.de, 2007-02-24 # Free for all uses. _gem() { local cur prev completions COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} COMMANDS='build cert check cleanup contents dependency\ environment help install list query rdoc search specification\ uninstall unpack update' COMMON_OPTIONS='\ --source -p --http-proxy --no-http-proxy\ -h --help\ --config-file\ --backtrace\ --debug' CERT_OPTIONS='\ -a -add\ -l --list\ -r --remove\ -b --build\ -C --certificate\ -K --private-key\ -s --sign' CHECK_OPTIONS='\ -v --verify\ -a --alien\ -t --test\ -V --version' CLEANUP_OPTIONS='\ -d --dry-run' CONTENTS_OPTIONS='\ -l --list\ -V --version\ -s --spec-dir\ -v --verbose' DEPENDENCY_OPTIONS='\ -v --version\ -r --reverse-dependencies --no-reverse-dependencies\ -p --pipe' HELP_OPTIONS=$COMMANDS INSTALL_OPTIONS='\ -v --version\ -l --local\ -r --remote\ -b --both\ -i --install-dir\ -B --build-root\ -d --rdoc --no-rdoc\ --ri --no-ri\ -f --force --no-force\ -t --test --no-test\ -w --wrappers --no-wrappers\ -P --trust-policy\ --ignore-dependencies\ -y --include-dependencies' LIST_OPTIONS='\ -d --details --no-details\ -l --local\ -r --remote\ -b --both' QUERY_OPTIONS='\ -n --name-matches\ -d --details --no-details\ -l --local\ -r --remote\ -b --both' RDOC_OPTIONS='\ --all\ --rdoc --no-rdoc\ --ri --no-ri\ -v --version' SEARCH_OPTIONS='\ -d --details --no-details\ -l --local\ -r --remote\ -b --both' SPECIFICATION_OPTIONS='\ -v --version\ -l --local\ -r --remote\ -b --both\ -all' UNINSTALL_OPTIONS='\ -a --all --no-all\ -i --ignore-dependencies --no-ignore-dependencies\ -x --executables --no-executables\ -v --version' UNPACK_OPTIONS='\ -v --version' UPDATE_OPTIONS='\ -i --install-dir\ -B --build-root\ -d --rdoc --no-rdoc\ -ri --no-ri\ -f --force --no-force\ -t --test --no-test\ -w --wrappers --no-wrappers\ -P --trust-policy\ --ignore-dependencies\ -y --include-dependencies\ --system' case "${prev}" in build) completions="$COMMON_OPTIONS $BUILD_OPTIONS" ;; cert) completions="$COMMON_OPTIONS $CERT_OPTIONS" ;; check) completions="$COMMON_OPTIONS $CHECK_OPTIONS" ;; cleanup) completions="$COMMON_OPTIONS $CLEANUP_OPTIONS" ;; contents) completions="$COMMON_OPTIONS $CONTENTS_OPTIONS" ;; dependency) completions="$COMMON_OPTIONS $DEPENDENCY_OPTIONS" ;; environment) completions="$COMMON_OPTIONS $ENVIRONMENT_OPTIONS" ;; help) completions="$COMMON_OPTIONS $HELP_OPTIONS" ;; install) completions="$COMMON_OPTIONS $INSTALL_OPTIONS" ;; list) completions="$COMMON_OPTIONS $LIST_OPTIONS" ;; query) completions="$COMMON_OPTIONS $QUERY_OPTIONS" ;; rdoc) completions="$COMMON_OPTIONS $RDOC_OPTIONS" ;; search) completions="$COMMON_OPTIONS $SEARCH_OPTIONS" ;; specification) completions="$COMMON_OPTIONS $SPECIFICATION_OPTIONS" ;; uninstall) completions="$COMMON_OPTIONS $UNINSTALL_OPTIONS" ;; unpack) completions="$COMMON_OPTIONS $UNPACK_OPTIONS" ;; update) completions="$COMMON_OPTIONS $UPDATE_OPTIONS" ;; *) completions="$COMMANDS $COMMON_OPTIONS" ;; esac COMPREPLY=( $( compgen -W "$completions" -- $cur )) return 0 } [ -n "${have:-}" ] && complete -F _gem $filenames gem