diff -r f96733ecc878 -r 950f332cc02b usr/src/cmd/zsh/Completion/Solaris/Command/_pkg5 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/cmd/zsh/Completion/Solaris/Command/_pkg5 Tue Feb 23 00:53:20 2010 +0200 @@ -0,0 +1,324 @@ +#compdef pkg + +_pkg5_pkgs() { + local cache_policy cache_id=pkg5_installed_pkgs:$HOST:${pkg5_root//\//+} + typeset -a -g _pkg5_installed_pkgs + + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _pkg5_installed_caching_policy + fi + + if ( [[ $#_pkg5_installed_pkgs -eq 0 ]] || _cache_invalid $cache_id ) && ! _retrieve_cache $cache_id; then + _pkg5_installed_pkgs=( $( + pkg -R $pkg5_root list -H | while read pkg junk; do + pkga=( ${(s:/:)pkg} ) + for i in {1..$#pkga}; do + print ${(j:/:)${pkga[$i,-1]}} + done + done) ) + _store_cache $cache_id _pkg5_installed_pkgs + fi + + compadd "$@" - ${_pkg5_installed_pkgs} +} + +_pkg5_pkgs_a() { + local cache_policy cache_id=pkg5_known_pkgs:$HOST:${pkg5_root//\//+} + typeset -a -g _pkg5_known_pkgs + + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _pkg5_known_caching_policy + fi + + if ( [[ $#_pkg5_known_pkgs -eq 0 ]] || _cache_invalid $cache_id ) && ! _retrieve_cache $cache_id; then + _pkg5_known_pkgs=( $( + pkg -R $pkg5_root list -aH --no-refresh | while read pkg junk; do + pkga=( ${(s:/:)pkg} ) + for i in {1..$#pkga}; do + print ${(j:/:)${pkga[$i,-1]}} + done + done) ) + _store_cache $cache_id _pkg5_known_pkgs + fi + + compadd "$@" - ${_pkg5_known_pkgs} +} + +_pkg5_pubs() { + compadd "$@" - $(pkg -R $pkg5_root publisher -H | awk '{print $1}') +} + +_pkg5_variants() { + compadd "$@" - $(pkg -R $pkg5_root variant -H | awk '{print $1}') +} + +_pkg5_facets() { + compadd "$@" - $(pkg -R $pkg5_root facet -H | awk '{print $1}') +} + +_pkg5_properties() { + compadd "$@" - $(pkg -R $pkg5_root property -H | awk '{print $1}') +} + +_pkg5_known_caching_policy() { + [[ $pkg5_root/var/pkg/state/known/catalog.attrs -nt "$1" ]] +} + +_pkg5_installed_caching_policy() { + [[ $pkg5_root/var/pkg/state/installed/catalog.attrs -nt "$1" ]] +} + +_pkg5() { + local expl context state line pkg5_root + typeset -A opt_args + local -a subcmds pkg5_actions pkg5_cattr pkg5_sattr + + subcmds=( + install uninstall list image-update refresh version + info search verify fix contents image-create history + {change-,}{variant,facet} + {{un,}set-,}property {{un,}set-,}publisher + purge-history rebuild-index + ) + + pkg5_actions=( + set depend dir driver file group hardlink legacy license link + signature unknown user + ) + + # Pseudo attributes for the contents subcommand + pkg5_cattr=( + action.hash action.key action.name action.raw + pkg.fmri pkg.name pkg.publisher pkg.shortfmri + ) + + # Pseudo attributes for the search subcommand + pkg5_sattr=( + $pkg5_cattr search.match search.match_type + ) + + if [[ $service == "pkg" ]]; then + _arguments -C -A "-*" \ + '(-\? --help)'{-\?,--help}'[Help]' \ + '-R[Root directory]:directory:_path_files -/' \ + '*::command:->subcmd' && return 0 + + if (( CURRENT == 1 )); then + _wanted commands expl "pkg subcommand" compadd -a subcmds + return + fi + service="$words[1]" + curcontext="${curcontext%:*}=$service:" + fi + + pkg5_root=${${${opt_args[-R]}:-$PKG_IMAGE}:-/} + + case $service in + ("install") + _arguments -A "-*" \ + '-n[Dry run]' \ + '-q[Quiet]' \ + '-v[Verbose]' \ + "--no-refresh[Don't refresh catalogs]" \ + "--no-index[Don't reindex search database]" \ + '*:package:_pkg5_pkgs_a' + ;; + + ("uninstall") + _arguments -A "-*" \ + '-n[Dry run]' \ + '-q[Quiet]' \ + '-r[Recursively uninstall dependencies]' \ + '-v[Verbose]' \ + "--no-index[Don't reindex search database]" \ + '*:package:_pkg5_pkgs' + ;; + + ("list") + _arguments -A "-*" \ + '-H[Omit headers]' \ + '-a[Show not-installed packages]' \ + '-f[Show all versions]' \ + '-n[Show newest versions]' \ + '-s[Show summaries]' \ + '-u[Show upgradable versions]' \ + '-v[Show verbose pkg: FMRIs]' \ + "--no-refresh[Don't refresh catalogs]" \ + '*:package:_pkg5_pkgs_a' + ;; + + ("image-update") + _arguments -A "-*" \ + "-f[Don't check for pkg(5) updates]" \ + '-n[Dry run]' \ + '-q[Quiet]' \ + '-v[Verbose]' \ + '--be-name[Set new boot environment name]:name:' \ + "--no-refresh[Don't refresh catalogs]" \ + "--no-index[Don't reindex search database]" + ;; + + ("refresh") + _arguments -A "-*" \ + "--full[Full refresh]" \ + '*:publisher:_pkg5_pubs' + ;; + + ("info") + _arguments -A "-*" \ + '--license[Display license text(s)]' \ + '(-r)-l[Installed package]' \ + '(-l)-r[Uninstalled package; fetch info from depot]:*:package:_pkg5_pkgs_a' \ + '*:package:_pkg5_pkgs' + ;; + + ("search") + _arguments -A "-*" \ + "(-p)-a[Show matching actions]" \ + '-l[Local search]' \ + '(-a)-p[Show packages]' \ + '-r[Remote search]' \ + '-H[Omit headers]' \ + '-I[Case sensitive search]' \ + '-s[Depot URI]' \ + '*-o[Attribute output]:attributes:_values -s , "attribute" $pkg5_sattr' \ + ':query:' + ;; + + ("verify") + _arguments -A "-*" \ + '-H[Omit headers]' \ + '-q[Quiet]' \ + '-v[Verbose]' \ + '*:package:_pkg5_pkgs' + ;; + + ("fix") + _arguments -A "-*" \ + '--accept[Force acceptance of license(s)]' \ + '--licenses[Display license text(s)]' \ + '*:package:_pkg5_pkgs' + ;; + + ("contents") + _arguments -A "-*" \ + '-H[Omit headers]' \ + '-m[Print raw manifests]' \ + '*-a[Attribute matching]:attribute=pattern:' \ + '*-o[Attribute output]:attributes:_values -s , "attribute" $pkg5_cattr' \ + '*-s[Sort key]:attribute:' \ + '*-t[Action type]:action:_values -s , "action" $pkg5_actions' \ + '-r[Fetch manifests from depot]:*:package:_pkg5_pkgs_a' \ + '*:package:_pkg5_pkgs' + ;; + + ("image-create") + _arguments -A "-*" \ + '(-f --force)'{-f,--force}'[Force image creation]' \ + '(-F --full -P --partial -U --user)'{-F,--full}'[Full image]' \ + '(-F --full -P --partial -U --user)'{-P,--partial}'[Partial image]' \ + '(-F --full -P --partial -U --user)'{-U,--user}'[User image]' \ + '(-z --zone)'{-z,--zone}'[Zoned image]' \ + '-k[Path to SSL key]:file:_path_files' \ + '-c[Path to SSL cert]:file:_path_files' \ + "--no-refresh[Don't refresh catalogs]" \ + "*--variant[Specify image variants]:variant=instance:" \ + "*--facet[Specify image facets]:facet=True/False:" \ + '(-p --publisher)'{-p,--publisher}'[Specify publisher]:prefix=URI:' \ + ':directory:_path_files -/' + ;; + + ("change-variant") + _arguments -A "-*" \ + '-n[Dry run]' \ + '-q[Quiet'] \ + '-v[Verbose'] \ + '--be-name[Set new boot environment name]:name:' \ + "*:variant:_values -s , 'variant' $(pkg -R $pkg5_root variant -H | awk '{print $1}')" \ + ;; + + ("change-facet") + _arguments -A "-*" \ + '-n[Dry run]' \ + '-q[Quiet'] \ + '-v[Verbose'] \ + '--be-name[Set new boot environment name]:name:' \ + "*:facet:_values -s , 'facet' $(pkg -R $pkg5_root facet -H | awk '{print $1}')" \ + ;; + + ("variant") + _arguments -A "-*" \ + '-H[Omit headers]' \ + '*:variant:_pkg5_variants' + ;; + + ("facet") + _arguments -A "-*" \ + '-H[Omit headers]' \ + '*:facet:_pkg5_facets' + ;; + + ("set-property") + _arguments -A "-*" \ + ':property:_pkg5_properties' \ + ':value:' + ;; + + ("unset-property") + _arguments -A "-*" \ + '*:property:_pkg5_properties' + ;; + + ("property") + _arguments -A "-*" \ + '-H[Omit headers]' \ + '*:property:_pkg5_properties' + ;; + + ("set-publisher") + _arguments -A "-*" \ + '-P[Make preferred]' \ + '(-e --enable)'{-e,--enable}'[Enable publisher]' \ + '(-d --disable)'{-d,--disable}'[Disable publisher]' \ + '(-g --add-origin)'{-g,--add-origin}'[Add origin URI]:uri:' \ + '(-G --remove-origin)'{-G,--remove-origin}'[Remove origin URI]:uri:' \ + '(-m --add-mirror)'{-m,--add-mirror}'[Add mirror URI]:uri:' \ + '(-M --remove-mirror)'{-M,--remove-mirror}'[Remove mirror URI]:uri:' \ + '-p[Repository URI]:url:' \ + "--no-refresh[Don't refresh catalogs]" \ + '--reset-uuid[Reset the image UUID for this publisher]' \ + '--sticky[Make this publisher sticky]' \ + '--non-sticky[Make this publisher non-sticky]' \ + '--search-after[Set publisher search-order]:publisher:_pkg5_pubs' \ + '--search-before[Set publisher search-order]:publisher:_pkg5_pubs' \ + ':publisher:_pkg5_pubs' + ;; + + ("unset-publisher") + _arguments -A "-*" \ + '*:publisher:_pkg5_pubs' + ;; + + ("publisher") + _arguments -A "-*" \ + '-H[Omit headers]' \ + '-P[Display only preferred publisher]' \ + '-n[Display only enabled publishers]' \ + '*:publisher:_pkg5_pubs' + ;; + + ("history") + _arguments -A "-*" \ + '-H[Omit headers]' \ + '-l[Long history]' + ;; + + (*) + _message "unknown pkg subcommand: $service" ;; + + esac +} + +_pkg5 "$@"