Date: Fri, 19 Oct 2012 01:49:54 +0900 From: Hajimu UMEMOTO <ume@freebsd.org> To: gtodd@bellanet.org Cc: FreeBSD Ports <freebsd-ports@freebsd.org> Subject: Re: zsh/pkg - solaris completions used for pkgNG Message-ID: <ygea9vjend9.wl%ume@mahoroba.org> In-Reply-To: <alpine.BSF.2.00.1210181046350.86367@wawanesa.iciti.ca> References: <alpine.BSF.2.00.1210181046350.86367@wawanesa.iciti.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
--Multipart_Fri_Oct_19_01:49:54_2012-1 Content-Type: text/plain; charset=US-ASCII Hi, >>>>> On Thu, 18 Oct 2012 11:07:20 -0400 (EDT) >>>>> gtodd@bellanet.org said: gtodd> A fix is to write completion for pkgNG one day ;-) or, for now, to gtodd> simply remove that file from the zsh port. My guess is the _pkg5 gtodd> functions can be hacked a bit to fit the needs of a very simple pkgNG gtodd> but I haven't started doing that yet. I was getting annoyed by this issue, too. So, I'm writing a completion for pkgNG. I've attached it for your interest. It is far from complete, though. Further work is welcome. :-) Sincerely, --Multipart_Fri_Oct_19_01:49:54_2012-1 Content-Type: application/octet-stream Content-Disposition: attachment; filename="_pkgng" Content-Transfer-Encoding: 7bit #compdef pkg _pkgng_pkgs() { local _pkgng_installed_pkgs _pkgng_installed_pkgs=($(pkg info -aq)) _describe -t packages "installed ports" _pkgng_installed_pkgs } _pkgng_ports() { _files -X "%Bports%b" -W "${PORTSDIR:-/usr/ports}" -/ } _pkgng_pkgs_ports() { local _pkgng_installed_pkgs local array ret=1 _tags packages ports while _tags; do if _requested packages; then _pkgng_installed_pkgs=($(pkg info -aq)) _describe -t packages "installed ports" _pkgng_installed_pkgs && ret=0 fi if _requested ports; then _files -X "%Bports%b" -W "${PORTSDIR:-/usr/ports}" -/ && ret=0 fi (( ret )) || return ret done } _pkgng() { local expl local -a subcmds subcmds=( add audit autoremove backup check clean create delete fetch help info install query register remove repo rquery search set shell shlib stats update updating upgrade version which ) if [[ $service == "pkg" ]]; then _arguments -C -A "-*" \ '-d[Increment debug level]' \ '-j[Execute pkg(1) inside a jail(8)]:jail name or id: ' \ '-c[Execute pkg(1) inside a chroot(8)]:chroot path:_path_files -/' \ '-v[Display pkg(1) version]' \ '*::command:->subcmd' && return 0 if (( CURRENT == 1 )); then _wanted commands expl "pkg subcommand" compadd -a subcmds return fi service="$words[1]" fi case $service in ("add") _arguments \ '*:package name:_files' ;; ("audit") _arguments -A "-*" \ '-F[Fetch the database before checking.]' \ '-q[Be "quiet". Prints only the requested information without displaying many hints.]' ;; ("autoremove") _arguments -A "-*" \ '-y[Assume yes when asked for confirmation before package autoremoval.]' \ '-n[Dry-run mode. The list of changes to packages is always printed, but no changes are actually made.]' \ '-q[Force quiet output]' ;; ("backup") ;; ("check") _arguments -A "-*" \ '-B[reanalyse SHLIBS of installed packages.]' \ '-d[check for and install missing dependencies.]' \ '-r[recompute sizes and checksums of installed packages.]' \ '-s[find invalid checksums for installed packages.]' \ \ '-y[Assume yes when asked for confirmation before installing missing dependencies.]' \ '-v[Be verbose.]' \ '-a[Process all packages.]' \ '-g[Treat <pattern> as a shell glob pattern.]' \ '-x[Treat <pattern> as a regular expression.]' \ '-X[Treat <pattern> as an extended regular expression.]' ;; ("clean") ;; ("create") ;; ("delete") _arguments -A "-*" \ '-a[Deletes all installed packages from the system and empties the database.]' \ '-f[Forces packages to be removed despite leaving unresolved dependencies.]' \ '-g[Treat the package names as shell glob patterns.]' \ '-n[Dry run mode. The list of packages to delete is always printed, but no packages are actually deleted.]' \ '-q[Force quiet output, except where -n is also used, when pkg delete will show the list of packages to be deleted.]' \ '-R[Delete all packages that require the listed packages as well.]' \ '-X[Treat the package names as extended regular expressions.]' \ '-x[Treat the package names as regular expressions.]' \ '-y[Assume yes when asked for confirmation before package deletion.]' \ '*:package:_pkgng_pkgs' ;; ("fetch") ;; ("help") _arguments -s \ ':command:_values -S " " -w "commands" $subcmds[@]' ;; ("info") _arguments -A "-*" \ '-a[Display all installed packages.]' \ '-f[Display full information about the packages matching <pkg-name>.]' \ '-R[Display the full yaml (raw) about the packages matching <pkg-name>.]' \ '-e[If <pkg-name> is installed and registered in the database, return 0, otherwise return 1. Useful for checking whether the package is installed.]' \ '-D[Show the pkg-message for matching packages.]' \ '-g[Treat <pkg-name> as a shell glob pattern.]' \ '-x[Treat <pkg-name> as a regular expression.]' \ '-X[Treat <pkg-name> as an extended regular expression.]' \ '-d[Display the list of packages required by <pkg-name>.]' \ '-r[Display the list of packages which depend on <pkg-name>.]' \ '-l[Display all files installed by <pkg-name>.]' \ '-B[Display all shared libraries used by <pkg-name>.]' \ '-s[Display the total size of files installed by <pkg-name>]' \ '-q[Be "quiet". Prints only the requested information without displaying many hints.]' \ '-O[Search is done by the <pkg-name> origin. Added only for Ports compatibility.]' \ '-E[Currently not implemented. Added only for Ports compatibility.]' \ '-o[Display <pkg-name> origin.]' \ '-p[Display the installation prefix for each package matching <pkg-name>.]' \ '-F[-F <pkg-file> Displays information from the package archive <pkg-file>.]' \ '*:package:_pkgng_pkgs' ;; ("install") ;; ("query") _arguments -A "-*" \ '-a[Match all packages from the database]' \ '-e[Match packages using the given evaluation-condition.]' \ '-F[Display information only for the package file pkg-name]' \ '-g[Treat <pattern> as a glob pattern.]' \ '-x[Treat <pattern> as a regular expression.]' \ '-X[Treat <pattern> as an extended regular expression.]' \ '*:package:_pkgng_pkgs' ;; ("register") ;; ("remove") _arguments -A "-*" \ '-a[Deletes all installed packages from the system and empties the database.]' \ '-f[Forces packages to be removed despite leaving unresolved dependencies.]' \ '-g[Treat the package names as shell glob patterns.]' \ '-n[Dry run mode. The list of packages to delete is always printed, but no packages are actually deleted.]' \ '-q[Force quiet output, except where -n is also used, when pkg delete will show the list of packages to be deleted.]' \ '-R[Delete all packages that require the listed packages as well.]' \ '-X[Treat the package names as extended regular expressions.]' \ '-x[Treat the package names as regular expressions.]' \ '-y[Assume yes when asked for confirmation before package deletion.]' \ '*:package:_pkgng_pkgs' ;; ("repo") ;; ("rquery") ;; ("search") _arguments -A "-*" \ '-e[Treat pattern as exact pattern]' \ '-g[Treat pattern as a shell glob pattern.]' \ '-x[Treat pattern as a regular expression.]' \ '-X[Treat pattern as an extended regular expression.]' \ '-c[Search for pattern in the package comment one-line description.]' \ '-D[Search for pattern in the package desription.]' \ '-f[Displays full information about the matching packages.]' \ '-d[Displays the dependencies of pattern]' \ '-s[Displays the size of the package]' \ '-q[Be "quiet". Prints only the requested information without displaying many hints.]' \ '-o[Displays pattern origin.]' \ '-p[Displays the installation prefix for each package matching pattern]' \ '*:package:_pkgng_pkgs_ports' ;; ("set") ;; ("shell") ;; ("shlib") _arguments -s \ '*:library:_files' # XXX: ;; ("stats") _arguments -A "-*" \ '-q[Quiet mode. Show less output.]' \ '-l[Display stats only for the local package database.]' \ '-r[Display stats only for the remote package database(s).]' ;; ("update") _arguments -A "-*" \ '-q[Force quiet output]' \ '-f[Force a full download of the repository catalogue without regard to the respective ages of the local and remote copies of the catalogue]' ;; ("updating") _arguments -A "-*" \ '-d[Only entries newer than date are shown.]:date (YYYYMMDD)' \ '-f[Defines a alternative location of the UPDATING file.]:file:_files' \ '*:package:_pkgng_pkgs_ports' ;; ("upgrade") _arguments -A "-*" \ '-f[Force reinstalling/upgrading the whole set of packages]' \ '-L[Skip updating the repository catalogues with pkg-update(8). Use the local cache only.]' \ '-n[Dry-run mode: show what packages have updates available, but do not perform any upgrades. Repository catalogues will be updated as usual unless the -L option is also given.]' \ '-q[Force quiet output, except when -n is used, where pkg upgrade will always print out the list of packages with available updates.]' \ '-y[Assume yes when asked for confirmation before package installation.]' \ '-r[Package repository.]:reponame' \ ;; ("version") ;; ("which") _arguments -A "-*" \ '-q[Be quiet]' \ '-o[Shows the origin of the package instead of name-version]' \ ':file:_files' ;; (*) _message "unknown pkg subcommand: $service" ;; esac } _pkgng "$@" --Multipart_Fri_Oct_19_01:49:54_2012-1 Content-Type: text/plain; charset=US-ASCII --Multipart_Fri_Oct_19_01:49:54_2012-1 Content-Type: text/plain -- Hajimu UMEMOTO ume@mahoroba.org ume@{,jp.}FreeBSD.org http://www.mahoroba.org/~ume/ --Multipart_Fri_Oct_19_01:49:54_2012-1--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ygea9vjend9.wl%ume>