Merge lp:~nobuto/powernap/bash-completion into lp:~kirkland/powernap/trunk

Proposed by Nobuto Murata
Status: Merged
Merge reported by: Dustin Kirkland 
Merged at revision: not available
Proposed branch: lp:~nobuto/powernap/bash-completion
Merge into: lp:~kirkland/powernap/trunk
Diff against target: 48 lines (+38/-0)
2 files modified
debian/powerwake.install (+1/-0)
powerwake_completion (+37/-0)
To merge this branch: bzr merge lp:~nobuto/powernap/bash-completion
Reviewer Review Type Date Requested Status
Dustin Kirkland  Approve
Review via email: mp+22569@code.launchpad.net

Description of the change

added support bash completion for powerwake.

With this change, users can use bash completion for options, hostnames and IP addresses.

To post a comment you must log in.
lp:~nobuto/powernap/bash-completion updated
145. By Nobuto Murata

* powerwake_completion: fix typo

146. By Nobuto Murata

format code (no functional change)

147. By Nobuto Murata

* powerwake_completion:
  - add completion for --broadcast option

Revision history for this message
Dustin Kirkland  (kirkland) :
review: Approve
Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Sorry it took me so long... Thanks for the code!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/powerwake.install'
2--- debian/powerwake.install 2009-07-01 23:28:21 +0000
3+++ debian/powerwake.install 2010-04-01 10:06:29 +0000
4@@ -1,1 +1,2 @@
5 powerwake usr/bin
6+powerwake_completion etc/bash_completion.d
7
8=== added file 'powerwake_completion'
9--- powerwake_completion 1970-01-01 00:00:00 +0000
10+++ powerwake_completion 2010-04-01 10:06:29 +0000
11@@ -0,0 +1,37 @@
12+# powerwake(1) completion
13+
14+have powerwake &&
15+_powerwake()
16+{
17+ local cur prev options files targets
18+ COMPREPLY=()
19+ cur="${COMP_WORDS[COMP_CWORD]}"
20+ prev="${COMP_WORDS[COMP_CWORD-1]}"
21+ options="-b --broadcast -m --method"
22+ files="/etc/ethers /var/cache/powerwake/ethers"
23+ targets="$( cat ${files} 2>/dev/null | awk '{print $2}' )"
24+
25+ case "${prev}" in
26+ -@(b|-broadcast))
27+ COMPREPLY=( $( compgen -W "$( LANG=C ifconfig 2>/dev/null | \
28+ awk '/Bcast:/ {print $3}' | awk -F ":" '{print $2}' )" \
29+ -- ${cur} ) )
30+ return 0
31+ ;;
32+ -@(m|-method))
33+ COMPREPLY=( $( compgen -W "wol" -- ${cur} ) )
34+ return 0
35+ ;;
36+ *)
37+ ;;
38+ esac
39+
40+ if [[ ${cur} == -* ]] ; then
41+ COMPREPLY=( $( compgen -W "${options}" -- ${cur} ) )
42+ return 0
43+ else
44+ COMPREPLY=( $( compgen -W "${targets}" -- ${cur} ) );
45+ return 0
46+ fi
47+}
48+complete -F _powerwake powerwake

Subscribers

People subscribed via source and target branches