Merge lp:~darkxst/ppa-purge/bash-completion into lp:ppa-purge

Proposed by Tim Lunn
Status: Merged
Merge reported by: Tim Lunn
Merged at revision: not available
Proposed branch: lp:~darkxst/ppa-purge/bash-completion
Merge into: lp:ppa-purge
Diff against target: 196 lines (+108/-12)
5 files modified
debian/changelog (+5/-0)
debian/control (+1/-1)
debian/ppa-purge.bash-completion (+80/-0)
debian/rules (+1/-1)
ppa-purge (+21/-10)
To merge this branch: bzr merge lp:~darkxst/ppa-purge/bash-completion
Reviewer Review Type Date Requested Status
Robert Hooker Pending
ppa-purge Pending
Review via email: mp+138373@code.launchpad.net

Description of the change

I have added bash autocompletion for installed ppas and also a few of the other options. I had to changes the options slightly since its a real pain to complete strings with a ':', however the script is still backwards compatible with the old use i.e. ppa:name/ppa still works but wont have bash completion.

To post a comment you must log in.
62. By Tim Lunn

fix changelog version

63. By Tim Lunn

fix tabs in usage page

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-11-30 10:12:27 +0000
3+++ debian/changelog 2012-12-06 04:10:23 +0000
4@@ -1,3 +1,8 @@
5+ppa-purge (0.2.8+bzr58) raring; urgency=low
6+
7+ * Add bash autocompletion and tweak options slightly. (LP: #1064205)
8+ -- Tim Lunn <tim@feathertop.org> Thu, 06 Dec 2012 14:12:52 +1100
9+
10 ppa-purge (0.2.8+bzr57) raring; urgency=low
11
12 [ Tim Lunn ]
13
14=== modified file 'debian/control'
15--- debian/control 2012-11-30 10:12:27 +0000
16+++ debian/control 2012-12-06 04:10:23 +0000
17@@ -2,7 +2,7 @@
18 Section: utils
19 Priority: optional
20 Maintainer: Lorenzo De Liso <blackz@ubuntu.com>
21-Build-Depends: debhelper (>= 7.0.50~)
22+Build-Depends: debhelper (>= 7.0.50~), bash-completion
23 Standards-Version: 3.9.3
24 Homepage: https://launchpad.net/ppa-purge
25
26
27=== added file 'debian/ppa-purge.bash-completion'
28--- debian/ppa-purge.bash-completion 1970-01-01 00:00:00 +0000
29+++ debian/ppa-purge.bash-completion 2012-12-06 04:10:23 +0000
30@@ -0,0 +1,80 @@
31+# /usr/share/bash-completion/completions/ppa-purge
32+# Debian ppa-purge(1) completion -*- shell-script -*-
33+
34+_update_server(){
35+ local i
36+ for (( i=1; i < ${#words[@]}-1; i++)) ; do
37+ case "${words[i]}" in
38+ -s)
39+ SERVER=${words[i+1]}
40+ ;;
41+ *)
42+ ;;
43+ esac
44+ done
45+}
46+
47+_update_owner(){
48+ local i
49+ for (( i=1; i < ${#words[@]}-1; i++)) ; do
50+ case "${words[i]}" in
51+ -o)
52+ OWNER=${words[i+1]}
53+ ;;
54+ *)
55+ ;;
56+ esac
57+ done
58+}
59+
60+_ppa_names(){
61+ _update_server
62+ _update_owner
63+ grep -hs "^deb\ .*$SERVER" /etc/apt/sources.list.d/*.list | grep "$OWNER" | command sed "s#.*$SERVER\/.*\/\(.*\)\/.*#\1#"
64+}
65+
66+_ppa_host(){
67+ grep -hs "^deb\ .*tp\:\/\/.*\/.*\/.*" /etc/apt/sources.list.d/*.list | command sed "s#^deb.*\:\/\/\(.*\)\/.*\/.*/.*#\1#" | uniq
68+}
69+
70+_ppa_owner(){
71+ _update_server
72+ grep -hs "^deb\ .*$SERVER" /etc/apt/sources.list.d/*.list | command sed "s#.*$SERVER\/\(.*\)\/.*\/.*#\1#"
73+}
74+
75+_ppa_list(){
76+ _update_server
77+ _update_owner
78+ grep -hs "^deb\ .*$SERVER" /etc/apt/sources.list.d/*.list | grep "$OWNER" | command sed "s#.*$SERVER\/\(.*\/.*\)\/.*#\1#"
79+
80+}
81+_ppa_purge(){
82+ OWNER=""
83+ SERVER="ppa.launchpad.net"
84+ local cur prev words cword opts
85+ _init_completion || return
86+
87+ opts="-p -s -o -d -y -i -h"
88+
89+ case "${prev}" in
90+ -p)
91+ COMPREPLY=( $( compgen -W "$(_ppa_names)" -- $cur ) )
92+ return 0
93+ ;;
94+ -s)
95+ COMPREPLY=( $( compgen -W "$(_ppa_host)" -- $cur ) )
96+ return 0
97+ ;;
98+ -o)
99+ COMPREPLY=( $( compgen -W "$(_ppa_owner)" -- $cur ) )
100+ return 0
101+ ;;
102+ *)
103+ ;;
104+ esac
105+
106+ COMPREPLY=( $( compgen -W '${opts} $(_ppa_list)' -- "$cur" ) )
107+
108+ return 0
109+} &&
110+complete -F _ppa_purge ppa-purge
111
112=== modified file 'debian/rules'
113--- debian/rules 2010-07-23 23:46:57 +0000
114+++ debian/rules 2012-12-06 04:10:23 +0000
115@@ -1,4 +1,4 @@
116 #!/usr/bin/make -f
117 %:
118- dh $@
119+ dh $@ --with bash-completion
120
121
122=== modified file 'ppa-purge'
123--- ppa-purge 2012-11-21 09:30:49 +0000
124+++ ppa-purge 2012-12-06 04:10:23 +0000
125@@ -31,6 +31,7 @@
126 echo
127 echo "Options:"
128 echo " -p [ppaname] PPA name to be disabled (default: ppa)"
129+ echo " -o [ppaowner] PPA owner"
130 echo " -s [host] Repository server (default: ppa.launchpad.net)"
131 echo " -d [distribution] Override the default distribution choice."
132 echo " -y Pass "-y --force-yes" to apt-get or "-y" to aptitude"
133@@ -38,13 +39,13 @@
134 echo " -h Display this help text"
135 echo
136 echo "Example usage commands:"
137- echo " sudo ppa-purge xorg-edgers"
138+ echo " sudo ppa-purge -o xorg-edgers"
139 echo " will remove https://launchpad.net/~xorg-edgers/+archive/ppa"
140 echo
141- echo " sudo ppa-purge -p xorg-testing sarvatt"
142+ echo " sudo ppa-purge -o sarvatt -p xorg-testing"
143 echo " will remove https://launchpad.net/~sarvatt/+archive/xorg-testing"
144 echo
145- echo " sudo ppa-purge ppa:ubuntu-x-swat/x-updates"
146+ echo " sudo ppa-purge [ppa:]ubuntu-x-swat/x-updates"
147 echo " will remove https://launchpad.net/~ubuntu-x-swat/+archive/x-updates"
148 echo
149 echo "Notice: If ppa-purge fails for some reason and you wish to try again,"
150@@ -54,22 +55,27 @@
151 exit $1
152 }
153
154+
155 # Command line options
156-while getopts "p:s:d:yih\?" opt; do
157+while getopts "p:o:s:d:yih\?" opt; do
158 case "$opt" in
159 p ) PPANAME="$OPTARG" ;;
160- s ) PPAHOST="$OPTARG" ;;
161- d ) DIST="$OPTARG" ;;
162+ o ) PPAOWNER="$OPTARG" ;;
163+ s ) PPAHOST="$OPTARG" ;;
164+ d ) DIST="$OPTARG" ;;
165 y ) FORCEINSTALL="true" ;;
166- i ) APTALT="true" ;;
167- h ) usage 0; ;;
168- \?) usage 1; ;;
169+ i ) APTALT="true" ;;
170+ h ) usage 0; ;;
171+ \?) usage 1; ;;
172 * ) warn "Unknown option '$opt'"; usage 1; ;;
173 esac
174 done
175 shift $(($OPTIND -1))
176
177-PPAOWNER=$1
178+if [ -z "$PPAOWNER" ]; then
179+ PPAOWNER=$1
180+fi
181+
182 APTARG=""
183 if [ ! -z "$APTALT" ]; then
184 if [ ! -z "$FORCEINSTALL" ]; then
185@@ -86,6 +92,11 @@
186 if echo $1 | grep -q "^ppa:"; then
187 PPAOWNER=$(echo $1 | sed "s#^ppa:\(.*\)/\(.*$\)#\1#")
188 PPANAME=$(echo $1 | sed "s#^ppa:\(.*\)/\(.*$\)#\2#")
189+else
190+ if echo $1 | grep -q "^.*/.*$"; then
191+ PPAOWNER=$(echo $1 | sed "s#^\(.*\)/\(.*$\)#\1#")
192+ PPANAME=$(echo $1 | sed "s#^\(.*\)/\(.*$\)#\2#")
193+ fi
194 fi
195
196 if [ -z "$PPAOWNER" ]; then

Subscribers

People subscribed via source and target branches

to all changes: