Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: rmmod/modprobe -r completion



> Hmm, this is fine but I'd have used a state or cached the loaded array
> and passed it to _arguments. Which is more efficient - functions
> declared in the autoloaded functions or states?

Well, modprobe could benefit from the use of states, so here's
modprobe supporting a few more options:


Index: Completion/Unix/Command/_modutils
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_modutils,v
retrieving revision 1.2
diff -u -r1.2 _modutils
--- Completion/Unix/Command/_modutils	2001/05/15 15:14:21	1.2
+++ Completion/Unix/Command/_modutils	2001/05/16 11:59:02
@@ -32,12 +32,37 @@
              '(-v)--verbose' \
              '(--version)-V[print version]' \
              '(-V)--version' \
-             '*:loaded module:_modutils_loaded_modules'
+             '*:loaded module:_modutils_loaded_modules' && return 0
   ;;
 
   modprobe)
-  _arguments '(--remove)-r[remove]:loaded module:_modutils_loaded_modules' \
-             '(-r)--remove:loaded module:_modutils_loaded_modules'
+
+  _modprobe_arguments=(
+             '(--all)-a[all]' \
+             '(-a)--all' \
+             '(--showconfig)-c[showconfig]' \
+             '(-c)--showconfig' \
+             '(--debug)-d[debug]' \
+             '(-d)--debug' \
+             '(--autoclean)-k[set autoclean]' \
+             '(-k)--autoclean' \
+             '(--show)-n[do not act]' \
+             '(-n)--show'
+  )
+
+  _arguments '(--remove)-r[remove]:*:loaded module:->modprobe_remove' \
+             '(-r)--remove:*:loaded module:->modprobe_remove' \
+	     "$_modprobe_arguments[@]" && return 0
+
+  ;;
+
+esac 
+
+case "$state" in
+  modprobe_remove)
+        _call_function ret _modutils_$state && return ret
+        _arguments "$_modprobe_arguments[@]" \
+                   '*:loaded module:_modutils_loaded_modules'
   ;;
 
 esac



Messages sorted by: Reverse Date, Date, Thread, Author