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
=== modified file 'debian/changelog'
--- debian/changelog 2012-11-30 10:12:27 +0000
+++ debian/changelog 2012-12-06 04:10:23 +0000
@@ -1,3 +1,8 @@
1ppa-purge (0.2.8+bzr58) raring; urgency=low
2
3 * Add bash autocompletion and tweak options slightly. (LP: #1064205)
4 -- Tim Lunn <tim@feathertop.org> Thu, 06 Dec 2012 14:12:52 +1100
5
1ppa-purge (0.2.8+bzr57) raring; urgency=low6ppa-purge (0.2.8+bzr57) raring; urgency=low
27
3 [ Tim Lunn ]8 [ Tim Lunn ]
49
=== modified file 'debian/control'
--- debian/control 2012-11-30 10:12:27 +0000
+++ debian/control 2012-12-06 04:10:23 +0000
@@ -2,7 +2,7 @@
2Section: utils2Section: utils
3Priority: optional3Priority: optional
4Maintainer: Lorenzo De Liso <blackz@ubuntu.com>4Maintainer: Lorenzo De Liso <blackz@ubuntu.com>
5Build-Depends: debhelper (>= 7.0.50~)5Build-Depends: debhelper (>= 7.0.50~), bash-completion
6Standards-Version: 3.9.36Standards-Version: 3.9.3
7Homepage: https://launchpad.net/ppa-purge7Homepage: https://launchpad.net/ppa-purge
88
99
=== added file 'debian/ppa-purge.bash-completion'
--- debian/ppa-purge.bash-completion 1970-01-01 00:00:00 +0000
+++ debian/ppa-purge.bash-completion 2012-12-06 04:10:23 +0000
@@ -0,0 +1,80 @@
1# /usr/share/bash-completion/completions/ppa-purge
2# Debian ppa-purge(1) completion -*- shell-script -*-
3
4_update_server(){
5 local i
6 for (( i=1; i < ${#words[@]}-1; i++)) ; do
7 case "${words[i]}" in
8 -s)
9 SERVER=${words[i+1]}
10 ;;
11 *)
12 ;;
13 esac
14 done
15}
16
17_update_owner(){
18 local i
19 for (( i=1; i < ${#words[@]}-1; i++)) ; do
20 case "${words[i]}" in
21 -o)
22 OWNER=${words[i+1]}
23 ;;
24 *)
25 ;;
26 esac
27 done
28}
29
30_ppa_names(){
31 _update_server
32 _update_owner
33 grep -hs "^deb\ .*$SERVER" /etc/apt/sources.list.d/*.list | grep "$OWNER" | command sed "s#.*$SERVER\/.*\/\(.*\)\/.*#\1#"
34}
35
36_ppa_host(){
37 grep -hs "^deb\ .*tp\:\/\/.*\/.*\/.*" /etc/apt/sources.list.d/*.list | command sed "s#^deb.*\:\/\/\(.*\)\/.*\/.*/.*#\1#" | uniq
38}
39
40_ppa_owner(){
41 _update_server
42 grep -hs "^deb\ .*$SERVER" /etc/apt/sources.list.d/*.list | command sed "s#.*$SERVER\/\(.*\)\/.*\/.*#\1#"
43}
44
45_ppa_list(){
46 _update_server
47 _update_owner
48 grep -hs "^deb\ .*$SERVER" /etc/apt/sources.list.d/*.list | grep "$OWNER" | command sed "s#.*$SERVER\/\(.*\/.*\)\/.*#\1#"
49
50}
51_ppa_purge(){
52 OWNER=""
53 SERVER="ppa.launchpad.net"
54 local cur prev words cword opts
55 _init_completion || return
56
57 opts="-p -s -o -d -y -i -h"
58
59 case "${prev}" in
60 -p)
61 COMPREPLY=( $( compgen -W "$(_ppa_names)" -- $cur ) )
62 return 0
63 ;;
64 -s)
65 COMPREPLY=( $( compgen -W "$(_ppa_host)" -- $cur ) )
66 return 0
67 ;;
68 -o)
69 COMPREPLY=( $( compgen -W "$(_ppa_owner)" -- $cur ) )
70 return 0
71 ;;
72 *)
73 ;;
74 esac
75
76 COMPREPLY=( $( compgen -W '${opts} $(_ppa_list)' -- "$cur" ) )
77
78 return 0
79} &&
80complete -F _ppa_purge ppa-purge
081
=== modified file 'debian/rules'
--- debian/rules 2010-07-23 23:46:57 +0000
+++ debian/rules 2012-12-06 04:10:23 +0000
@@ -1,4 +1,4 @@
1#!/usr/bin/make -f1#!/usr/bin/make -f
2%:2%:
3 dh $@3 dh $@ --with bash-completion
44
55
=== modified file 'ppa-purge'
--- ppa-purge 2012-11-21 09:30:49 +0000
+++ ppa-purge 2012-12-06 04:10:23 +0000
@@ -31,6 +31,7 @@
31 echo31 echo
32 echo "Options:"32 echo "Options:"
33 echo " -p [ppaname] PPA name to be disabled (default: ppa)"33 echo " -p [ppaname] PPA name to be disabled (default: ppa)"
34 echo " -o [ppaowner] PPA owner"
34 echo " -s [host] Repository server (default: ppa.launchpad.net)"35 echo " -s [host] Repository server (default: ppa.launchpad.net)"
35 echo " -d [distribution] Override the default distribution choice."36 echo " -d [distribution] Override the default distribution choice."
36 echo " -y Pass "-y --force-yes" to apt-get or "-y" to aptitude"37 echo " -y Pass "-y --force-yes" to apt-get or "-y" to aptitude"
@@ -38,13 +39,13 @@
38 echo " -h Display this help text"39 echo " -h Display this help text"
39 echo40 echo
40 echo "Example usage commands:"41 echo "Example usage commands:"
41 echo " sudo ppa-purge xorg-edgers"42 echo " sudo ppa-purge -o xorg-edgers"
42 echo " will remove https://launchpad.net/~xorg-edgers/+archive/ppa"43 echo " will remove https://launchpad.net/~xorg-edgers/+archive/ppa"
43 echo44 echo
44 echo " sudo ppa-purge -p xorg-testing sarvatt"45 echo " sudo ppa-purge -o sarvatt -p xorg-testing"
45 echo " will remove https://launchpad.net/~sarvatt/+archive/xorg-testing"46 echo " will remove https://launchpad.net/~sarvatt/+archive/xorg-testing"
46 echo47 echo
47 echo " sudo ppa-purge ppa:ubuntu-x-swat/x-updates"48 echo " sudo ppa-purge [ppa:]ubuntu-x-swat/x-updates"
48 echo " will remove https://launchpad.net/~ubuntu-x-swat/+archive/x-updates"49 echo " will remove https://launchpad.net/~ubuntu-x-swat/+archive/x-updates"
49 echo50 echo
50 echo "Notice: If ppa-purge fails for some reason and you wish to try again,"51 echo "Notice: If ppa-purge fails for some reason and you wish to try again,"
@@ -54,22 +55,27 @@
54 exit $155 exit $1
55}56}
5657
58
57# Command line options59# Command line options
58while getopts "p:s:d:yih\?" opt; do60while getopts "p:o:s:d:yih\?" opt; do
59 case "$opt" in61 case "$opt" in
60 p ) PPANAME="$OPTARG" ;;62 p ) PPANAME="$OPTARG" ;;
61 s ) PPAHOST="$OPTARG" ;;63 o ) PPAOWNER="$OPTARG" ;;
62 d ) DIST="$OPTARG" ;;64 s ) PPAHOST="$OPTARG" ;;
65 d ) DIST="$OPTARG" ;;
63 y ) FORCEINSTALL="true" ;;66 y ) FORCEINSTALL="true" ;;
64 i ) APTALT="true" ;;67 i ) APTALT="true" ;;
65 h ) usage 0; ;;68 h ) usage 0; ;;
66 \?) usage 1; ;;69 \?) usage 1; ;;
67 * ) warn "Unknown option '$opt'"; usage 1; ;;70 * ) warn "Unknown option '$opt'"; usage 1; ;;
68 esac71 esac
69done72done
70shift $(($OPTIND -1))73shift $(($OPTIND -1))
7174
72PPAOWNER=$175if [ -z "$PPAOWNER" ]; then
76 PPAOWNER=$1
77fi
78
73APTARG=""79APTARG=""
74if [ ! -z "$APTALT" ]; then80if [ ! -z "$APTALT" ]; then
75 if [ ! -z "$FORCEINSTALL" ]; then81 if [ ! -z "$FORCEINSTALL" ]; then
@@ -86,6 +92,11 @@
86if echo $1 | grep -q "^ppa:"; then92if echo $1 | grep -q "^ppa:"; then
87 PPAOWNER=$(echo $1 | sed "s#^ppa:\(.*\)/\(.*$\)#\1#")93 PPAOWNER=$(echo $1 | sed "s#^ppa:\(.*\)/\(.*$\)#\1#")
88 PPANAME=$(echo $1 | sed "s#^ppa:\(.*\)/\(.*$\)#\2#")94 PPANAME=$(echo $1 | sed "s#^ppa:\(.*\)/\(.*$\)#\2#")
95else
96 if echo $1 | grep -q "^.*/.*$"; then
97 PPAOWNER=$(echo $1 | sed "s#^\(.*\)/\(.*$\)#\1#")
98 PPANAME=$(echo $1 | sed "s#^\(.*\)/\(.*$\)#\2#")
99 fi
89fi100fi
90101
91if [ -z "$PPAOWNER" ]; then102if [ -z "$PPAOWNER" ]; then

Subscribers

People subscribed via source and target branches

to all changes: