File: m-a

package info (click to toggle)
module-assistant 0.9sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 660 kB
  • ctags: 169
  • sloc: perl: 1,218; sh: 306; makefile: 186
file content (78 lines) | stat: -rw-r--r-- 2,054 bytes parent folder | download
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
#-*- mode: shell-script;-*-
# Inputs:
#   $1 -- name of the command whose arguments are being completed
#   $2 -- word being completed
#   $3 -- word preceding the word being completed
#   $COMP_LINE  -- current command line
#   $COMP_PONT  -- cursor position
#   $COMP_WORDS -- array containing individual words in the current
#                  command line
#   $COMP_CWORD -- index into ${COMP_WORDS} of the word containing the
#                  current cursor position
# Output:
#   COMPREPLY array variable contains possible completions

#
# Syntax (simple:
#   module-assistant  [options] command module [module ...]

have module-assistant &&
_module_assistant() {

   local cur prev special i options commands

   options='-h -v -q -n -i -o -s -f -u -k -l \
   --help --verbose --quiet --no-rebuild --non-inter --unpack-once \
   --apt-search --force --userdir --kernel-dir --kvers-list'

   commands='update unpack get build list install auto-install prepare clean purge la li a-i'

	COMPREPLY=()
	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}

	for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
		if [[ ${COMP_WORDS[i]} == @(update|unpack|get|build|list|install|auto-install|clean|purge|la|list-available|li|list-installed|a-i) ]]; then
			special=${COMP_WORDS[i]}
		fi
	done

	if [ -n "$special" ]; then
		case $special in
		clean|purge)
			COMPREPLY=( $( module-assistant -q compi $cur 2> /dev/null ) )
			return 0
			;;
		*)
			COMPREPLY=( $( module-assistant -q comp $cur 2> /dev/null ) )
			return 0
			;;

		esac
	fi

	case "$prev" in
	    -@(u|k|-kernel-dir|-kernel-dirs))
 		     _filedir
		     return 0
		     ;;

	    -@(l|-kver-list))
		     COMPREPLY=( $( module-assistant -q compv $cur ) )
		     return 0
		     ;;
	esac

	if [[ "$cur" == -* ]]; then
		COMPREPLY=( $( compgen -W "$options" -- $cur ) )
	else
		COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
	fi

	return 0

}
[ "$have" ] && complete -F _module_assistant $filenames module-assistant
[ "$have" ] && complete -F _module_assistant $filenames m-a