21
21
# being sourced before it and thus before the `module' alias has been defined.
22
22
[[ -f /etc/profile.d/modules.sh ]] || return 1
23
23
24
- # TODO:API: rename per conventions, rework to use vars rather than outputting
25
- _module_list ()
24
+ _comp_cmd_module__compgen_list ()
26
25
{
27
26
local modules=" $( command sed ' s/:/ /g' <<< " $LOADEDMODULES" | sort) "
28
- compgen -W " $modules " -- " $1 "
27
+ _comp_compgen -- -W " $modules "
29
28
}
30
29
31
- # TODO:API: rename per conventions, rework to use vars rather than outputting
32
- _module_path ()
30
+ _comp_cmd_module__compgen_path ()
33
31
{
34
32
local modules=" $( command sed ' s/:/ /g' <<< " $MODULEPATH" | sort) "
35
- compgen -W " $modules " -- " $1 "
33
+ _comp_compgen -- -W " $modules "
36
34
}
37
35
38
- # TODO:API: rename per conventions, rework to use vars rather than outputting
39
- _module_avail ()
36
+ _comp_cmd_module__compgen_avail ()
40
37
{
41
38
local modules=" $(
42
39
module avail 2>&1 |
43
40
command grep -E -v ' ^(-|$)' |
44
41
xargs printf ' %s\n' | command sed -e ' s/(default)//g' | sort
45
42
) "
46
-
47
- compgen -W " $modules " -- " $1 "
43
+ _comp_compgen -- -W " $modules "
48
44
}
49
45
50
46
# A completion function for the module alias
@@ -65,19 +61,23 @@ _comp_cmd_module()
65
61
elif (( cword == 2 )) ; then
66
62
case $prev in
67
63
add | display | help | load | show | whatis)
68
- COMPREPLY=($( _module_avail " $cur " ) )
64
+ # TODO:API: use generator call?
65
+ _comp_cmd_module__compgen_avail
69
66
;;
70
67
rm | switch | swap | unload | update)
71
- COMPREPLY=($( _module_list " $cur " ) )
68
+ # TODO:API: use generator call?
69
+ _comp_cmd_module__compgen_list
72
70
;;
73
71
unuse)
74
- COMPREPLY=($( _module_path " $cur " ) )
72
+ # TODO:API: use generator call?
73
+ _comp_cmd_module__compgen_path
75
74
;;
76
75
esac
77
76
elif (( cword == 3 )) ; then
78
77
case ${words[1]} in
79
78
swap | switch)
80
- COMPREPLY=($( _module_avail " $cur " ) )
79
+ # TODO:API: use generator call?
80
+ _comp_cmd_module__compgen_avail
81
81
;;
82
82
esac
83
83
fi
0 commit comments