From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: _initctl: only define helper functions once
Date: Thu, 26 May 2011 18:05:23 +0200 [thread overview]
Message-ID: <1306425923-6895-1-git-send-email-mikachu@gmail.com> (raw)
In-Reply-To: <20110526103606.0d7cd39a@pwslap01u.europe.root.pri>
---
Completion/Unix/Command/_initctl | 69 ++++++++++++++++++++------------------
1 files changed, 36 insertions(+), 33 deletions(-)
diff --git a/Completion/Unix/Command/_initctl b/Completion/Unix/Command/_initctl
index 08145b1..850064d 100644
--- a/Completion/Unix/Command/_initctl
+++ b/Completion/Unix/Command/_initctl
@@ -2,29 +2,6 @@
# Written by Bernhard Tittelbach
# based on completion script by Mildred
-local -a common_args
-common_args=(
- '--session[use D-Bus session bus to connect to init daemon (for testing)]'
- '--system[talk via DBUS system bus instead of socket]'
- '(-q --quiet)'{-q,--quiet}'[reduce output to errors only]'
- '(-v --verbose)'{-v,--verbose}'[increase output to include informational messages]'
- '--dest=[D-Bus name for init, defaults to com.ubuntu.Upstart]'
- '--help[display help and exit]'
- '--version[output version information and exit]'
-)
-
-# don't overwrite work that we might have already done
-if (( ${+_initctl_events_list} + ${+_initctl_eventargs_list} != 2 )); then
- typeset -g -a -U _initctl_events_list _initctl_eventargs_list
-fi
-
-# map each initctl function to a completion function
-local -A cmd_completion_funcs
-cmd_completion_funcs=( start startstop stop startstop restart startstop reload startstop show-config show-config status argjob emit emit check-config check-config )
-
-# define fallback completion function
-local cmd_completion_default=basic
-
# run show-config -e and if possible parse out all events and KEY= argumnts
# otherwise provide some common values
_initctl_fillarray_events_args ()
@@ -169,13 +146,39 @@ _initctl_check-config()
'*::'
}
-# depending on which command was used, call different completion funtions
-case $service in
- initctl)
- _arguments "${common_args[@]}" '*::Initctl Commands:_initctl_command'
- ;;
- start|stop|restart|reload|status)
- _call_function ret _initctl_${cmd_completion_funcs[${service}]-${cmd_completion_default}}
- ;;
- *) return 1 ;;
-esac
+_initctl()
+{
+ local -a common_args
+ common_args=(
+ '--session[use D-Bus session bus to connect to init daemon (for testing)]'
+ '--system[talk via DBUS system bus instead of socket]'
+ '(-q --quiet)'{-q,--quiet}'[reduce output to errors only]'
+ '(-v --verbose)'{-v,--verbose}'[increase output to include informational messages]'
+ '--dest=[D-Bus name for init, defaults to com.ubuntu.Upstart]'
+ '--help[display help and exit]'
+ '--version[output version information and exit]'
+ )
+
+ # don't overwrite work that we might have already done
+ if (( ${+_initctl_events_list} + ${+_initctl_eventargs_list} != 2 )); then
+ typeset -g -a -U _initctl_events_list _initctl_eventargs_list
+ fi
+
+ # map each initctl function to a completion function
+ local -A cmd_completion_funcs
+ cmd_completion_funcs=( start startstop stop startstop restart startstop reload startstop show-config show-config status argjob emit emit check-config check-config )
+
+ # define fallback completion function
+ local cmd_completion_default=basic
+
+ # depending on which command was used, call different completion funtions
+ case $service in
+ initctl)
+ _arguments "${common_args[@]}" '*::Initctl Commands:_initctl_command'
+ ;;
+ start|stop|restart|reload|status)
+ _call_function ret _initctl_${cmd_completion_funcs[${service}]-${cmd_completion_default}}
+ ;;
+ *) return 1 ;;
+ esac
+}
--
1.7.4-rc1
next prev parent reply other threads:[~2011-05-26 16:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-25 17:17 zsh completion for upstart commands initctl start stop restart reload and status Bernhard Tittelbach
2011-05-25 20:50 ` Marc Weber
2011-05-26 9:36 ` Peter Stephenson
2011-05-26 16:05 ` Mikael Magnusson [this message]
2011-05-26 16:11 ` PATCH: _initctl: only define helper functions once Peter Stephenson
2011-05-26 16:49 ` Mikael Magnusson
2011-05-26 19:37 ` Bernhard Tittelbach
2011-05-26 19:42 ` Mikael Magnusson
2011-05-26 20:31 ` Bernhard Tittelbach
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=1306425923-6895-1-git-send-email-mikachu@gmail.com \
--to=mikachu@gmail.com \
--cc=zsh-workers@zsh.org \
/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).