[Bash-completion-commits] [bash-completion] 01/01: chronyc: Parse command args from help output
Ville Skyttä
scop-guest at moszumanska.debian.org
Wed Oct 7 07:38:30 UTC 2015
This is an automated email from the git hooks/post-receive script.
scop-guest pushed a commit to branch master
in repository bash-completion.
commit 5fd00776c49f1d4552630c986e70f21e4a6028ad
Author: Ville Skyttä <ville.skytta at iki.fi>
Date: Wed Oct 7 10:38:06 2015 +0300
chronyc: Parse command args from help output
---
completions/chronyc | 47 ++++++++++++++++-------------------------------
1 file changed, 16 insertions(+), 31 deletions(-)
diff --git a/completions/chronyc b/completions/chronyc
index ddbbbb9..166d325 100644
--- a/completions/chronyc
+++ b/completions/chronyc
@@ -1,5 +1,16 @@
# chronyc(1) completion -*- shell-script -*-
+_chronyc_command_args()
+{
+ local -a args=( $( compgen -W "$( $1 help 2>/dev/null | \
+ awk '/^'$prev'\s[^ []/ { gsub("\\|", " ", $2); print $2 }' )" ) )
+ case $args in
+ \<address\>) _known_hosts_real "$cur" ;;
+ \<*) ;;
+ *) COMPREPLY+=( $( compgen -W '${args[@]}' -- "$cur" ) ) ;;
+ esac
+}
+
_chronyc()
{
local cur prev words cword
@@ -32,37 +43,11 @@ _chronyc()
-- "$cur" ) )
;;
1)
- case $prev in
- accheck|cmdaccheck|delete|maxdelay|maxdelayratio|\
- maxdelaydevratio|maxpoll|minpoll|minstratum|polltarget)
- _known_hosts_real "$cur"
- ;;
- add)
- COMPREPLY=( $( compgen -W 'peer server' -- "$cur" ) )
- ;;
- allow|cmdallow|cmddeny|deny)
- COMPREPLY=( $( compgen -W 'all' -- "$cur" ) )
- ;;
- authhash)
- COMPREPLY=( $( compgen -W 'MD5 SHA1' -- "$cur" ) )
- ;;
- dns)
- COMPREPLY=( $( compgen -W '-n +n -4 -6 -46' -- "$cur" ) )
- ;;
- local)
- COMPREPLY=( $( compgen -W 'off stratum' -- "$cur" ) )
- ;;
- manual)
- COMPREPLY=( $( compgen -W 'list on off reset delete' \
- -- "$cur" ) )
- ;;
- sources|sourcestats)
- COMPREPLY=( $( compgen -W '-v' -- "$cur" ) )
- ;;
- smoothtime)
- COMPREPLY=( $( compgen -W 'reset activate' -- "$cur" ) )
- ;;
- esac
+ _chronyc_command_args "$1"
+ if [[ ! $COMPREPLY && $prev == sources?(tats) ]]; then
+ # [-v] not handled by _chronyc_command_args yet
+ COMPREPLY=( $( compgen -W '-v' -- "$cur" ) )
+ fi
;;
2)
[[ $prev == @(peer|server) ]] && _known_hosts_real "$cur"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/bash-completion/bash-completion.git
More information about the Bash-completion-commits
mailing list