Skip to content

Commit

Permalink
Implemented completion for zerogwctl
Browse files Browse the repository at this point in the history
  • Loading branch information
tailhook committed Nov 9, 2011
1 parent 2399cc0 commit 19d4e3e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
28 changes: 28 additions & 0 deletions completion/bash
Original file line number Diff line number Diff line change
@@ -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

19 changes: 19 additions & 0 deletions completion/zsh
Original file line number Diff line number Diff line change
@@ -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 "$@"
6 changes: 6 additions & 0 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 19d4e3e

Please sign in to comment.