zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: _module
@ 2007-03-14 21:11 Clint Adams
  2007-03-14 21:25 ` Daniel Qarras
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Clint Adams @ 2007-03-14 21:11 UTC (permalink / raw)
  To: zsh-workers; +Cc: Daniel Qarras

Despite the generic name, this is not part of GNUstep; it's
http://modules.sourceforge.net/ .

Daniel, someone will need to work on filling in the additional
arguments.

Index: Completion/Unix/Command/_module
===================================================================
RCS file: Completion/Unix/Command/_module
diff -N Completion/Unix/Command/_module
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_module	14 Mar 2007 21:06:49 -0000
@@ -0,0 +1,29 @@
+#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
+    else
+      _files
+    fi
+  ;;
+esac


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: _module
  2007-03-14 21:11 PATCH: _module Clint Adams
@ 2007-03-14 21:25 ` Daniel Qarras
  2007-03-24  9:04 ` Daniel Qarras
  2007-03-27 18:58 ` Daniel Qarras
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Qarras @ 2007-03-14 21:25 UTC (permalink / raw)
  To: Clint Adams, zsh-workers

Hi Clint,

> Despite the generic name, this is not part of GNUstep; it's
> http://modules.sourceforge.net/ .
> 
> Daniel, someone will need to work on filling in the additional
> arguments.

thanks for your initiative! However, I guess the real meat would be
completion of the module files in $MODULEPATH or loaded module files
available with "module list". I'll inspect that later this week if you
don't beat me.

Thanks!


> 
> Index: Completion/Unix/Command/_module
> ===================================================================
> RCS file: Completion/Unix/Command/_module
> diff -N Completion/Unix/Command/_module
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ Completion/Unix/Command/_module	14 Mar 2007 21:06:49 -0000
> @@ -0,0 +1,29 @@
> +#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
> +    else
> +      _files
> +    fi
> +  ;;
> +esac
> 



 
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: _module
  2007-03-14 21:11 PATCH: _module Clint Adams
  2007-03-14 21:25 ` Daniel Qarras
@ 2007-03-24  9:04 ` Daniel Qarras
  2007-03-27 18:58 ` Daniel Qarras
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Qarras @ 2007-03-24  9:04 UTC (permalink / raw)
  To: Clint Adams, zsh-workers

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

Hi!

> Despite the generic name, this is not part of GNUstep; it's
> http://modules.sourceforge.net/ .
> 
> Daniel, someone will need to work on filling in the additional
> arguments.

I've now attached a complete version that completes also sub-commands
and module names. Please apply!

PS. I used your version and _yum as basis, hopefully everything is ok -
at least it works perfectly! :)

Cheers!


 
____________________________________________________________________________________
TV dinner still cooling? 
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/

[-- Attachment #2: 1603270985-_module --]
[-- Type: application/octet-stream, Size: 5486 bytes --]

#compdef module

# 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 'module command' _module_cmds || compadd "$@"
  else
    local curcontext="$curcontext"

    cmd="${${_module_cmds[(r)$words[1]:*]%%:*}}"
    # Deal with any aliases
    case $cmd in
      add) cmd="load";;
      rm) cmd="unload";;
      swap) cmd="switch";;
      show) cmd="display";;
      keyword) cmd="apropos";;
    esac
                
    if (( $#cmd ));
    then
      local update_policy
      curcontext="${curcontext%:*:*}:module-${cmd}:"
      zstyle -s ":completion:${curcontext}:" cache-policy update_policy
      _call_function ret _module_$cmd || _message 'no more arguments'
    else
      _message "unknown module command: $words[1]"
    fi

    return ret
  fi
}

# Fills the available modules cache
_module_available_modules()
{
  if (( [[ -n "$MODULEPATH" ]] && [[ ${+_available_modules} -eq 0 ]] ));
  then
    _available_modules=($(find ${(e)=MODULEPATH//:/ } -xtype f -print 2>/dev/null | grep -v \.version | sed -e 's,\('${${(e)=MODULEPATH//:/\/\\\|}%\\\|}'\),,g'))
  fi
}

# Completion function for help
(( $+functions[_module_help] )) || _module_help()
{
  _module_available_modules
  compadd "$@" -a -- _available_modules
}

# Completion function for load|add
(( $+functions[_module_load] )) || _module_load()
{
  _module_available_modules
  compadd "$@" -a -- _available_modules
}

# Completion function for unload|rm
(( $+functions[_module_unload] )) || _module_unload()
{
  compadd "$@" -- ${=LOADEDMODULES//:/ }
}

# Completion function for switch|swap
(( $+functions[_module_switch] )) || _module_switch()
{
  # Actually first argument could be a loaded module
  _module_available_modules
  compadd "$@" -a -- _available_modules
}

# Completion function for display|show
(( $+functions[_module_display] )) || _module_display()
{
  _module_available_modules
  compadd "$@" -a -- _available_modules
}

# Completion function for avail
### No completion (yet?)

# Completion function for use
(( $+functions[_module_use] )) || _module_use()
{
  _arguments -s \
    '(-a --append)'{--append,-a}'[Append the directories instead of prepending]' \
    '*:directory:_files -/'    
}

# Completion function for unuse
(( $+functions[_module_unuse] )) || _module_unuse()
{
  compadd "$@" -- ${=MODULEPATH//:/ }
}

# Completion function for whatis
(( $+functions[_module_whatis] )) || _module_whatis()
{
  _module_available_modules
  compadd "$@" -a -- _available_modules
}

# Completion function for initadd
(( $+functions[_module_initadd] )) || _module_initadd()
{
  _module_available_modules
  compadd "$@" -a -- _available_modules
}

# Completion function for initprepend
(( $+functions[_module_initprepend] )) || _module_initprepend()
{
  _module_available_modules
  compadd "$@" -a -- _available_modules
}

# Completion function for initrm
(( $+functions[_module_initrm] )) || _module_initrm()
{
  _module_available_modules
  compadd "$@" -a -- _available_modules
}

# Completion function for initswitch
(( $+functions[_module_initswitch] )) || _module_initswitch()
{
  _module_available_modules
  compadd "$@" -a -- _available_modules
}

_module "$@"

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: _module
  2007-03-14 21:11 PATCH: _module Clint Adams
  2007-03-14 21:25 ` Daniel Qarras
  2007-03-24  9:04 ` Daniel Qarras
@ 2007-03-27 18:58 ` Daniel Qarras
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Qarras @ 2007-03-27 18:58 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 537 bytes --]

Hi,

as some of you might know, there are two implementations of the Modules
system, C and Tcl versions. They should be compatible and I had done my
testing with C version but now I happened to try also the Tcl version.
It turned out that the attached small patch was needed.

Please apply, sorry for the inconvenience.

Thanks!


 
____________________________________________________________________________________
No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 3112873836-_module.patch --]
[-- Type: text/x-patch; name="_module.patch", Size: 539 bytes --]

--- zsh/Completion/Unix/Command/_module.orig
+++ zsh/Completion/Unix/Command/_module
@@ -85,7 +85,7 @@
 {
   if (( [[ -n "$MODULEPATH" ]] && [[ ${+_available_modules} -eq 0 ]] ));
   then
-    _available_modules=($(find ${(e)=MODULEPATH//:/ } -xtype f -print 2>/dev/null | grep -v \.version | sed -e 's,\('${${(e)=MODULEPATH//:/\/\\\|}%\\\|}'\),,g'))
+    _available_modules=($(find ${(e)=MODULEPATH//:/ } -xtype f -print 2>/dev/null | grep -v \.version | sed -e 's,\('${${(e)=MODULEPATH//:/\/\\\|}%\\\|}'\),,g' -e 's,^/*,,g'))
   fi
 }
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-03-28  0:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-14 21:11 PATCH: _module Clint Adams
2007-03-14 21:25 ` Daniel Qarras
2007-03-24  9:04 ` Daniel Qarras
2007-03-27 18:58 ` Daniel Qarras

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).