zsh-workers
 help / color / mirror / code / Atom feed
From: Clint Adams <clint@zsh.org>
To: zsh-workers@sunsite.dk
Subject: PATCH: _vserver
Date: Fri, 28 Apr 2006 14:35:00 -0400	[thread overview]
Message-ID: <20060428183500.GA23634@scowler.net> (raw)

_vserver from intrigeri@boum.org via Micah Anderson.

Index: Completion/Linux/Command/_vserver
===================================================================
RCS file: Completion/Linux/Command/_vserver
diff -N Completion/Linux/Command/_vserver
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Linux/Command/_vserver	28 Apr 2006 18:32:53 -0000
@@ -0,0 +1,131 @@
+#compdef vserver
+
+_vserver () {
+
+  # local variables
+  local curcontext="$curcontext" state line expl ret=1
+  local cmd=$words[3]
+  
+  # dispatch
+  case "$cmd" in
+    apt-cache|apt-config|apt-get)
+      compset -n 3
+      _dispatch $cmd:t $cmd $cmd:t -default- && ret=0
+      ;;
+    exec)
+      _arguments -C \
+	'1: :->vsnames' \
+	'2: :->cmds' \
+	'3:command name: _command_names -e'  \
+	'*::arguments: _normal' && ret=0
+      ;;
+    stop|restart|condrestart|enter|running|status)
+      _arguments -C \
+	'1: :->vsnames' \
+	'2: :->cmds' \
+	'*::arguments: _message "no more arguments"' && ret=0
+      ;;
+    *)
+      _arguments -C \
+	'(-)--help[print help information]' \
+	'(- *)--version[print client version information]' \
+	'1: :->vsnames' \
+	'2: :->cmds' \
+	'*:: :->args' && ret=0
+      ;;
+  esac
+  
+  # cache initialization
+  if [[ -n "$state" ]]; then
+    if (( ! $+_cache_vserver_cfgdir )); then
+      typeset -g _cache_vserver_cfgdir_initialized
+      _vserver_cache_cfgdir
+    fi
+    if (( ! $+_cache_vserver_vsnames )); then
+      typeset -g _cache_vserver_vsnames_initialized
+      _vserver_cache_vsnames
+    fi
+    if (( ! $+_cache_vserver_cmds )); then
+      typeset -g _cache_vserver_cmds_initialized
+      _vserver_cache_cmds
+    fi
+  fi
+
+  case "$state" in
+    vsnames)
+      _wanted commands expl 'vserver name' _vserver_vsnames && ret=0
+      ;;
+    cmds)
+      _wanted commands expl 'vserver command' _vserver_commands && ret=0
+      ;;
+    args)
+      local args
+      if $+args; then
+	_arguments "$args[@]" && ret=0
+      else
+	ret=0
+      fi
+      ;;
+  esac
+
+  return ret
+}
+
+(( $+functions[_vserver_commands] )) ||
+_vserver_commands() {
+  compadd "$@" -k _cache_vserver_cmds || compadd "$@" ${(s.:.)_cache_vserver_cmds}
+}
+
+(( $+functions[_svk_list_patches] )) ||
+_vserver_vsnames() {
+  local expl
+  _wanted vserver expl 'vserver name' compadd -S '' $_cache_vserver_vsnames[@]
+}
+
+(( $+functions[_vserver_cache_cfgdir] )) ||
+_vserver_cache_cfgdir() {
+  if [[ "$_cache_vserver_cfgdir_initialized" != true ]]; then
+    typeset -ga _cache_vserver_cfgdir
+    _cache_vserver_cfgdir=`vserver-info info SYSINFO | grep '^ *cfg-Directory' | awk '{print $2}'`
+    _cache_vserver_cfgdir_initialized=true
+  fi
+}
+
+(( $+functions[_vserver_cache_vsnames] )) ||
+_vserver_cache_vsnames() {
+  if [[ "$_cache_vserver_vsnames_initialized" != true ]]; then
+    typeset -ga _cache_vserver_vsnames
+    _cache_vserver_vsnames=( $(ls -d $_cache_vserver_cfgdir/*/ | sed -e s,$_cache_vserver_cfgdir,, | tr -d '/') )
+    _cache_vserver_vsnames_initialized=true
+  fi
+}
+
+(( $+functions[_vserver_cache_cmds] )) ||
+_vserver_cache_cmds() {
+  if [[ "$_cache_vserver_cmds_initialized" != true ]]; then
+    typeset -ga _cache_vserver_cmds
+      _cache_vserver_cmds=(
+      start
+      stop
+      restart
+      condrestart
+      suexec
+      exec
+      enter
+      chkconfig
+      running
+      status
+      build
+      unify
+      pkg
+      apt-get
+      apt-config
+      apt-cache
+      rpm
+      pkgmgmt	 
+    )
+    _cache_vserver_cmds_initialized=true
+  fi
+}
+
+_vserver "$@"


                 reply	other threads:[~2006-04-28 18:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060428183500.GA23634@scowler.net \
    --to=clint@zsh.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).