Debian Codegraph @

m-a

raw
1 #-*- mode: shell-script;-*-
2 # Inputs:
3 # $1 -- name of the command whose arguments are being completed
4 # $2 -- word being completed
5 # $3 -- word preceding the word being completed
6 # $COMP_LINE -- current command line
7 # $COMP_PONT -- cursor position
8 # $COMP_WORDS -- array containing individual words in the current
9 # command line
10 # $COMP_CWORD -- index into ${COMP_WORDS} of the word containing the
11 # current cursor position
12 # Output:
13 # COMPREPLY array variable contains possible completions
14
15 #
16 # Syntax (simple:
17 # module-assistant [options] command module [module ...]
18
19 _module_assistant() {
20
21 local cur prev special i options commands
22
23 options='-h -v -q -n -i -o -s -f -u -k -l \
24 --help --verbose --quiet --no-rebuild --non-inter --unpack-once \
25 --apt-search --force --userdir --kernel-dir --kvers-list'
26
27 commands='update unpack get fakesource build list install auto-install prepare clean purge la li a-i'
28
29 COMPREPLY=()
30 cur=${COMP_WORDS[COMP_CWORD]}
31 prev=${COMP_WORDS[COMP_CWORD-1]}
32
33 for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
34 if [[ ${COMP_WORDS[i]} == @(update|fakesource|unpack|get|build|list|install|auto-install|clean|purge|la|list-available|li|list-installed|a-i) ]]; then
35 special=${COMP_WORDS[i]}
36 fi
37 done
38
39 if [ -n "$special" ]; then
40 case $special in
41 clean|purge)
42 COMPREPLY=( $( module-assistant -q compi $cur 2> /dev/null ) )
43 return 0
44 ;;
45 *)
46 COMPREPLY=( $( module-assistant -q comp $cur 2> /dev/null ) )
47 return 0
48 ;;
49
50 esac
51 fi
52
53 case "$prev" in
54 -@(u|k|-kernel-dir|-kernel-dirs))
55 _filedir
56 return 0
57 ;;
58
59 -@(l|-kver-list))
60 COMPREPLY=( $( module-assistant -q compv $cur ) )
61 return 0
62 ;;
63 esac
64
65 if [[ "$cur" == -* ]]; then
66 COMPREPLY=( $( compgen -W "$options" -- $cur ) )
67 else
68 COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
69 fi
70
71 return 0
72
73 }
74 complete -F _module_assistant $filenames module-assistant
75 complete -F _module_assistant $filenames m-a
76
77