new completion: pkgadd
This commit is contained in:
parent
6ddec67c2f
commit
a54fa7340a
1
CHANGES
1
CHANGES
@ -3,6 +3,7 @@
|
|||||||
* nmcli: new completion
|
* nmcli: new completion
|
||||||
* svcadm: new completion, contributed by Yann Rouillard <yann@opencsw.org>
|
* svcadm: new completion, contributed by Yann Rouillard <yann@opencsw.org>
|
||||||
* pkg-get: new completion, contributed by Yann Rouillard <yann@opencsw.org>
|
* pkg-get: new completion, contributed by Yann Rouillard <yann@opencsw.org>
|
||||||
|
* pkgadd: new completion, contributed by Yann Rouillard <yann@opencsw.org>
|
||||||
|
|
||||||
bash-completion (2.0)
|
bash-completion (2.0)
|
||||||
|
|
||||||
|
@ -236,6 +236,7 @@ bashcomp_DATA = a2x \
|
|||||||
pkg-config \
|
pkg-config \
|
||||||
pkg-get \
|
pkg-get \
|
||||||
pkg_delete \
|
pkg_delete \
|
||||||
|
pkgadd \
|
||||||
pkgtool \
|
pkgtool \
|
||||||
plague-client \
|
plague-client \
|
||||||
pm-hibernate \
|
pm-hibernate \
|
||||||
|
59
completions/pkgadd
Normal file
59
completions/pkgadd
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
# pkgadd completion -*- shell-script -*-
|
||||||
|
#
|
||||||
|
# Copyright 2006 Yann Rouillard <yann@opencsw.org>
|
||||||
|
|
||||||
|
_pkgadd ()
|
||||||
|
{
|
||||||
|
local cur prev words cword
|
||||||
|
_init_completion -n : || return
|
||||||
|
|
||||||
|
# if a device directory was given
|
||||||
|
# we must complete with the package
|
||||||
|
# available in this directory
|
||||||
|
local device=/var/spool/pkg;
|
||||||
|
local i=$cword
|
||||||
|
while [[ $((i--)) -gt 0 ]]; do
|
||||||
|
case "${words[$i]}" in
|
||||||
|
-d)
|
||||||
|
device="${words[$((i+1))]}";
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac;
|
||||||
|
done;
|
||||||
|
|
||||||
|
case $prev in
|
||||||
|
-d)
|
||||||
|
_filedir pkg
|
||||||
|
_filedir -d
|
||||||
|
;;
|
||||||
|
-a|-r|-V)
|
||||||
|
_filedir
|
||||||
|
;;
|
||||||
|
-k|-s|-R)
|
||||||
|
_filedir -d
|
||||||
|
;;
|
||||||
|
-P|-k|-x)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [[ ${cur} == -* ]] ; then
|
||||||
|
local opts="-a -A -d -k -n -M -P -r -R -s -v -V -x"
|
||||||
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
|
else
|
||||||
|
local pkginst_list
|
||||||
|
if [[ -d $device ]]; then
|
||||||
|
for filedir in $(/bin/ls -1 $device); do
|
||||||
|
if [[ -d "$device/$filedir" ]] && [[ -f "$device/$filedir/pkginfo" ]]; then
|
||||||
|
pkginst_list+=( ${pkginst_list[@]:-} "$filedir" )
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
pkginst_list="${pkginst_list[@]}"
|
||||||
|
else
|
||||||
|
pkginst_list=$(strings $(dequote $device) | grep "^PKG=" | sort -u | cut -d= -f2)
|
||||||
|
fi
|
||||||
|
COMPREPLY=( $(compgen -W "$pkginst_list" -- ${cur}) )
|
||||||
|
fi
|
||||||
|
esac
|
||||||
|
} &&
|
||||||
|
complete -F _pkgadd pkgadd
|
||||||
|
|
||||||
|
# ex: ts=4 sw=4 et filetype=sh
|
1
test/completion/pkgadd.exp
Normal file
1
test/completion/pkgadd.exp
Normal file
@ -0,0 +1 @@
|
|||||||
|
assert_source_completions pkgadd
|
18
test/lib/completions/pkgadd.exp
Normal file
18
test/lib/completions/pkgadd.exp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
proc setup {} {
|
||||||
|
save_env
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc teardown {} {
|
||||||
|
assert_env_unmodified
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
setup
|
||||||
|
|
||||||
|
|
||||||
|
assert_complete_any "pkgadd "
|
||||||
|
sync_after_int
|
||||||
|
|
||||||
|
|
||||||
|
teardown
|
Loading…
x
Reference in New Issue
Block a user