From 9c402241c485ec6dea0915e071f70db2b2107246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 30 Dec 2009 22:59:17 +0200 Subject: [PATCH] Add rtcwake completion. --- CHANGES | 4 ++-- Makefile.am | 1 + contrib/rtcwake | 39 ++++++++++++++++++++++++++++++++ test/completion/rtcwake.exp | 3 +++ test/lib/completions/rtcwake.exp | 20 ++++++++++++++++ 5 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 contrib/rtcwake create mode 100644 test/completion/rtcwake.exp create mode 100644 test/lib/completions/rtcwake.exp diff --git a/CHANGES b/CHANGES index c76677a6..399f4344 100644 --- a/CHANGES +++ b/CHANGES @@ -29,8 +29,8 @@ bash-completion (2.x) mysqladmin, rsync, screen, service, scp, ssh, sshfs, update-alternatives, vncviewer, and general hostname completions. * Add abook and wtf completion, based on work by Raphaƫl Droz. - * Add cvsps, fusermount, jarsigner, k3b, lftpget, pm-utils, pack200 and - unpack200 completions. + * Add cvsps, fusermount, jarsigner, k3b, lftpget, pm-utils, rtcwake, pack200 + and unpack200 completions. * Don't overwrite other host completions when completing from multiple SSH known hosts files. * Speed up installed rpm package completion on SUSE, based on work by diff --git a/Makefile.am b/Makefile.am index 06309d33..db0fbab9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -117,6 +117,7 @@ bashcomp_DATA = contrib/abook \ contrib/rpmcheck \ contrib/rrdtool \ contrib/rsync \ + contrib/rtcwake \ contrib/samba \ contrib/sbcl \ contrib/screen \ diff --git a/contrib/rtcwake b/contrib/rtcwake new file mode 100644 index 00000000..42637e6f --- /dev/null +++ b/contrib/rtcwake @@ -0,0 +1,39 @@ +# bash completion for rtcwake + +have rtcwake && +_rtcwake() +{ + COMPREPLY=() + local cur=`_get_cword` prev=`_get_pword` split=false + + _split_longopt && split=true + + case "$prev" in + --help|-h|--version|-V|--seconds|-s|--time|-t) + return 0 + ;; + --mode|-m) + COMPREPLY=( $( compgen -W 'standby mem disk on no off' -- "$cur" ) ) + return 0 + ;; + --device|-d) + COMPREPLY=( $( command ls -d /dev/rtc* 2>/dev/null ) ) + COMPREPLY=( $( compgen -W '${COMPREPLY[@]#/dev/}' -- "$cur" ) ) + return 0 + ;; + esac + + $split && return 0 + + COMPREPLY=( $( compgen -W '--device --local --mode --seconds --time --utc \ + --verbose --version --help' -- "$cur" ) ) +} && +complete -F _rtcwake rtcwake + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh diff --git a/test/completion/rtcwake.exp b/test/completion/rtcwake.exp new file mode 100644 index 00000000..3970a42a --- /dev/null +++ b/test/completion/rtcwake.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type rtcwake]} { + source "lib/completions/rtcwake.exp" +}; # if diff --git a/test/lib/completions/rtcwake.exp b/test/lib/completions/rtcwake.exp new file mode 100644 index 00000000..0b9a974b --- /dev/null +++ b/test/lib/completions/rtcwake.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "rtcwake " + + +sync_after_int + + +teardown