1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
# Check for bash
[ -z "$BASH_VERSION" ] && return
__dahdi_span_assignments() {
local cur prev has_cmd i
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
has_cmd=0
for (( i=0; i < COMP_CWORD; i++)); do
case "${COMP_WORDS[$i]}" in
add | auto | dumpconfig | list | remove)
has_cmd=1
break
;;
esac
done
case "$prev" in
-k | --key) COMPREPLY=( $(compgen -W 'devpath hwid location' -- $cur) ) ;;
*)
case "$cur" in
-*) COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
'-h -k -n -v --help --key --dry-run --verbose' -- $cur ) )
;;
*)
if [ "$has_cmd" = 1 ]; then
COMPREPLY=( ${COMPREPLY[@]} $(shopt -s nullglob; \
echo /sys/bus/dahdi_devices/devices/* ) )
else
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
'add auto dumpconfig list remove' -- $cur) )
fi
;;
esac
;;
esac
}
complete -F __dahdi_span_assignments dahdi_span_assignments
__dahdi_span_types() {
local cur prev has_cmd i
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
has_cmd=0
for (( i=0; i < COMP_CWORD; i++)); do
case "${COMP_WORDS[$i]}" in
dumpconfig | list | set | compare)
has_cmd=1
break
;;
esac
done
case "$prev" in
-k | --key) COMPREPLY=( $(compgen -W 'devpath hwid location' -- $cur) ) ;;
--line-type) COMPREPLY=( $(compgen -W 'E1 J1 T1' -- $cur) ) ;;
*)
case "$cur" in
-*) COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
'-h -k -n -v --help --key --dry-run --line-type --verbose' -- $cur ) )
;;
*)
if [ "$has_cmd" = 1 ]; then
# FIXME: check if devices are settable?
COMPREPLY=( ${COMPREPLY[@]} $( \
grep -l '[EJT]1' /sys/devices/pci0000:00/0000:00:10.4/usb1/1-1/xbus-00/*/spantype 2>/dev/null | sed -e 's|/spantype||') )
else
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
'dumpconfig list set compare' -- $cur) )
fi
;;
esac
;;
esac
}
complete -F __dahdi_span_types dahdi_span_types
__dahdi_genconf() {
local cur
COMPREPLY=()
prev=${COMP_WORDS[COMP_CWORD-1]}
cur=${COMP_WORDS[COMP_CWORD]}
case "$prev" in
--line-type) COMPREPLY=( $(compgen -W 'E1 J1 T1' -- $cur) ) ;;
*)
case "$cur" in
-*) COMPREPLY+=( $(compgen -W '-F -v -V --freepbx --version --verbose --line-type' -- $cur ) ) ;;
*)
COMPREPLY+=( $(compgen -W "$( perl -e 'my $file = "\u$ARGV[0]";
# Complete module name. Translate the case of the
# first letter
my @pats = map {"$_/Dahdi/Config/Gen/$file*.pm"} @INC;
foreach (@pats) {
foreach(glob) {
s|.*/||;
s|.pm$||;
s|^(.)|lc($1)|e;
print "$_ "
}
}')" -- $cur ) )
;;
esac
;;
esac
}
complete -F __dahdi_genconf dahdi_genconf
__dahdi_cfg() {
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-c) COMPREPLY=( $(compgen -f -- $cur) ) ;;
-S) COMPREPLY=( $(ls -d /sys/bus/dahdi_spans/devices/* 2>/dev/null | sed -e 's/.*-//') ) ;;
# FIXME: A similar completion for -C (<chan1>-<chan2>)
*)
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
'-c -C -f -h -s -S -t -v ' -- $cur ) )
;;
esac
}
# Disable until -c works properly
#complete -F __dahdi_cfg dahdi_cfg
|