From c5ac4796428d1f2bb688e0fa4e593b476bc0ba4a Mon Sep 17 00:00:00 2001 From: Clint Adams Date: Sat, 24 Mar 2007 15:43:12 +0000 Subject: 23236: Daniel Qarras: enhancements for _module. --- Completion/Unix/Command/_module | 200 +++++++++++++++++++++++++++++++++++----- 1 file changed, 175 insertions(+), 25 deletions(-) (limited to 'Completion/Unix') diff --git a/Completion/Unix/Command/_module b/Completion/Unix/Command/_module index b44dbdb60..1df12a3d9 100644 --- a/Completion/Unix/Command/_module +++ b/Completion/Unix/Command/_module @@ -1,29 +1,179 @@ #compdef module -local context state line -typeset -A opt_args - -_arguments \ - '(-f --force)'{--force,-f}'[force active dependency resolution]' \ - '(-t --terse)'{--terse,-t}'[display avail and list output in short format]' \ - '(-l --long)'{--long,-l}'[display avail and list output in long format]' \ - '(-h --human)'{--human,-h}'[display short output in human-readable format]' \ - '(-v --verbose)'{--verbose,-v}'[verbose]' \ - '(-s --silent)'{--silent,-s}'[disable verbose messages]' \ - '(-c --create)'{--create,-c}'[create caches]' \ - '(-i --icase)'{--icase,-i}'[case insensitive]' \ - '(-i --icase)'{--icase,-i}'[case insensitive]' \ - '(-u --userlvl)'{--userlvl,-u}'[set user level to value]:level:(novice expert advanced)' \ - '*::command:->subcmds' && return 0 - -case "$state" in - (subcmds) - if (( CURRENT == 1 )); then - compadd -- help load add unload rm switch swap display show list \ - avail use unuse update clear purge whatis apropos keyword \ - initadd initprepend initswitch initlist initclear +# Main dispatcher +_module() +{ + _arguments -s \ + '(-H --help)'{--help,-H}'[display usage info]' \ + '(-V --version)'{--version,-V}'[module command version and configuration options]' \ + '(-f --force)'{--force,-f}'[force active dependency resolution]' \ + '(-t --terse)'{--terse,-t}'[display avail and list output in short format]' \ + '(-l --long)'{--long,-l}'[display avail and list output in long format]' \ + '(-h --human)'{--human,-h}'[display short output in human-readable format]' \ + '(-v --verbose)'{--verbose,-v}'[verbose]' \ + '(-s --silent)'{--silent,-s}'[disable verbose messages]' \ + '(-c --create)'{--create,-c}'[create caches]' \ + '(-i --icase)'{--icase,-i}'[case insensitive]' \ + '(-u --userlvl)'{--userlvl,-u}'[set user level to value]:level:(novice expert advanced)' \ + '*::module command:_module_command' +} + +(( $+functions[_module_command] )) || _module_command() +{ + local -a _module_cmds + + _module_cmds=( + "help:Print the usage of each sub-command" + "load:Load a module into the shell environment" + "add:Load a module into the shell environment" + "unload:Remove a module from the shell environment" + "rm:Remove a module from the shell environment" + "switch:Switch loaded a loaded module with another module" + "swap:Switch loaded a loaded module with another module" + "display:Display information about a module" + "show:Display information about a module" + "list:List loaded modules" + "avail:List all available modules" + "use:Add a directory to MODULEPATH" + "unuse:Remove a directory from MODULEPATH" + "update:Reload all loaded modules" + "clear:Clear loaded modules information" + "purge:Unload all loaded modules" + "refresh:Refresh all non-persistent components of loaded modules" + "whatis:Display module information" + "appropos:Search for a given keyword in modules" + "keyword:Search for a given keyword in modules" + "initadd:Add or append a module to the user's shell init file" + "initprepend:Add or prepend a module to the user's shell init files" + "initrm:Remove a module from the user's shell init file" + "initswitch:Switch modules in the user's shell init file" + "initlist:List all loaded modules in the user's shell init files" + "initclear:Clear all modules from the user's shell init files" + ) + + if (( CURRENT == 1 )); then + _describe -t commands '