#compdef port local subcmds # we cache the list of ports # we shall use some cache policy to avoid problems with new ports if (( ! $+portlist )); then portlist=($(port list | cut -f 1)) fi subcmds=( 'install' 'uninstall' 'installed' 'outdated' 'upgrade' 'deactivate' 'activate' 'clean' 'distclean' 'search' 'list' 'contents' 'deps' 'variants' 'info' 'fetch' 'extract' 'patch' 'configure' 'build' 'destroot' 'test' 'pkg' 'mpkg' 'dmg' 'rpmpackage' 'archive' 'unarchive' ) _arguments -C \ '-v[verbose mode (generate verbose messages)]' \ '-d[debug mode (generate debugging messages)]' \ '-q[quiet mode (suppress messages)]' \ '-D[specify portdir]' \ '-k[keep mode (do not autoclean after install)]' \ '-n[dont follow dependencies in upgrade (only for upgrading)]' \ '-a[upgrade all installed ports (only for upgrading)]' \ '-u[uninstall non-active ports when upgrading and uninstalling]' \ '-f[force mode (ignore state file)]' \ '-s[source-only mode]' \ '-b[binary-only mode]' \ '-o[honor state files older than Portfile]' \ '*::command:->command' \ && return 0 case $state in command) if ((CURRENT == 1)); then state=subcommands else state=portname fi ;; esac case $state in subcommands) _describe -t commands 'port commands' subcmds ;; portname) _describe -t commands 'available ports' portlist ;; esac