Permalink
Browse files

Implemented completion for zerogwctl

  • Loading branch information...
1 parent 2399cc0 commit 19d4e3e7d5a316719347c337a2412474d05b063c @tailhook committed Nov 9, 2011
Showing with 53 additions and 0 deletions.
  1. +28 −0 completion/bash
  2. +19 −0 completion/zsh
  3. +6 −0 wscript
View
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+_zerogwctl()
+{
+ local cur prev commands
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ commands=(
+ list_commands
+ get_statistics
+ pause_websockets
+ resume_websockets
+ reopen_logs
+ --help
+ -c --config
+ -s --socket
+ )
+ case "${prev}" in
+ -c|--config|-s|--socket)
+ COMPREPLY=( $(compgen -A file ${cur}) )
+ ;;
+ *)
+ COMPREPLY=( $(compgen -W "${commands[*]}" -- ${cur}) )
+ ;;
+ esac
+}
+complete -F _zerogwctl zerogwctl
+
View
@@ -0,0 +1,19 @@
+#compdef zerogwctl
+
+_zerogwctl() {
+ local commands
+ commands=(
+ list_commands
+ get_statistics
+ pause_websockets
+ resume_websockets
+ reopen_logs
+ )
+ _arguments -s \
+ '1:command:('"${commands[*]}"')' \
+ '--help[show help]' \
+ '(-s --socket -c --config)'{-c+,--config+}'[configuration file]:configuration file:_files -g "*.yaml"' \
+ '(-c -s --socket --config)'{-s+,--socket+}'[socket file]:socket file:_files'
+}
+
+_zerogwctl "$@"
View
@@ -69,8 +69,14 @@ def build(bld):
if bld.env['PREFIX'] == '/usr':
bld.install_files('/etc', ['examples/zerogw.yaml'])
+ bld.install_as('/etc/bash_completion.d/zerogwctl',
+ 'completion/bash')
else:
bld.install_files('${PREFIX}/etc', ['examples/zerogw.yaml'])
+ bld.install_as('${PREFIX}/etc/bash_completion.d/zerogwctl',
+ 'completion/bash')
+ bld.install_as('${PREFIX}/share/zsh/site-functions/_zerogwctl',
+ 'completion/zsh')
def dist(ctx):
ctx.excl = [

0 comments on commit 19d4e3e

Please sign in to comment.