[devscripts] 01/01: debdiff bash completion

Nicholas Bamber periapt at moszumanska.debian.org
Sat Dec 12 20:52:17 UTC 2015


This is an automated email from the git hooks/post-receive script.

periapt pushed a commit to branch master
in repository devscripts.

commit 877a9187440c01c5b1a82df466218eba623c4c2e
Author: Nicholas Bamber <nicholas at periapt.co.uk>
Date:   Sat Dec 12 20:47:48 2015 +0000

    debdiff bash completion
---
 debian/changelog                |  4 +-
 scripts/debdiff.bash_completion | 88 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index ed58bd3..a5ec5e2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -20,8 +20,8 @@ devscripts (2.15.10) UNRELEASED; urgency=medium
     + Added listcachedbugs command to bts
     + Split out bts bash completion handling into its own script
   * Added custom bash completion support for debuild, checkbashisms,
-    list-unreleased, dscverify, dscextract, what-patch, plotchangelog
-    and licensecheck
+    list-unreleased, dscverify, dscextract, what-patch, plotchangelog,
+    debdiff and licensecheck
   * Updated custom bash completion handling for mk-origtargz
   * Added debcheckout to those commands with package names bash completion
   * licensecheck:
diff --git a/scripts/debdiff.bash_completion b/scripts/debdiff.bash_completion
new file mode 100644
index 0000000..e2f33b5
--- /dev/null
+++ b/scripts/debdiff.bash_completion
@@ -0,0 +1,88 @@
+# Debian debdiff(1) completion                             -*- shell-script -*-
+# Copyright: 2015, Nicholas Bamber <nicholas at periapt.co.uk>
+_debdiff()
+{
+    local cur prev words cword _options i
+	local _dir=normal
+	local -i _from=-1
+	local -i _to=-1
+    _init_completion || return
+
+    for (( i=1; i<${#words[@]}; i++ )); do
+		if [[ $_dir == @(deb|dsc|changes) ]]; then
+			if (( i == ${#words[@]}-1 )); then
+				break
+			else
+				COMPREPLY=()
+				return 0
+			fi
+		fi
+		if (( ${_from} == -1  && ${_to} == -1 )); then
+			_dir=normal
+		elif (( ${_from} >= 0 && ${_to} == -1 )); then
+			_dir=from
+		elif (( ${_from} >= 0 && ${_to} >= 0 && ${_to} < ${_from} )); then
+			_dir=to
+		else
+			COMPREPLY=( ) 
+			return 0
+		fi
+		if [[ $_dir == normal && ${words[i]} == --from ]]; then
+			_from=0
+			_dir=from
+		elif [[ $_dir == normal && ${words[i]} == *.deb ]]; then
+			_dir=deb
+		elif [[ $_dir == normal && ${words[i]} == *.dsc ]]; then
+			_dir=dsc
+		elif [[ $_dir == normal && ${words[i]} == *.changes ]]; then
+			_dir=changes
+		elif [[ $_dir == from && ${words[i]} == *.deb ]]; then
+			(( ++_from ))
+		elif [[ $_dir == from && ${words[i]} == --to ]]; then
+			_to=0
+			_dir=to
+		elif [[ $_dir = to && ${words[i]} == *.deb ]]; then
+			(( ++_to ))
+		fi
+    done
+
+	if [[ $_dir == normal ]]; then
+
+		if [[ $prev == --debs-dir ]]; then
+			COMPREPLY=$( ( compgen -d -- "$cur" ) )
+		elif [[ $cur == -* ]]; then
+			_options='--from --dirs --nodirs --move --move-regex --nocontrol --control --controlfiles --wdiff-source-control --no-wdiff-source-control --wp --wl --wt --show-moved --noshow-moved --renamed --exclude --diffstat --no-diffstat --auto-ver-sort --no-auto-ver-sort --unpack-tarballs --no-unpack-tarballs --debs-dir --quiet --ignore-space'
+	
+			if [[ $prev == debdiff ]]; then
+				_options+=' --no-conf'
+			fi
+	
+			COMPREPLY=( $( compgen -W "${_options}" -- "$cur" ) )
+		else
+	        declare -a _compreply=( $( compgen -o filenames -G '*.@(deb|dsc|changes)' ) )
+	        COMPREPLY=( $( compgen -W "${_compreply[*]}"  -- "$cur" ) )
+		fi
+	elif [[ $_dir == deb ]]; then
+		declare -a _compreply=( $( compgen -o filenames -G '*.deb' ) )
+        COMPREPLY=( $( compgen -W "${_compreply[*]}"  -- "$cur" ) )
+	elif [[ $_dir = dsc ]]; then
+		declare -a _compreply=( $( compgen -o filenames -G '*.dsc' ) )
+        COMPREPLY=( $( compgen -W "${_compreply[*]}"  -- "$cur" ) )
+	elif [[ $_dir = changes ]]; then
+		declare -a _compreply=( $( compgen -o filenames -G '*.changes' ) )
+        COMPREPLY=( $( compgen -W "${_compreply[*]}"  -- "$cur" ) )
+	else
+	    _options=$(find . -name '*.deb' | sed -e's!\.\/!!' |  paste -s -d' ')
+		if [[ $_dir == from ]]; then
+			if (( $_from > 0 )); then
+				_options+=' --to'
+			fi
+		fi
+		COMPREPLY=( $( compgen -W "${_options}" -- "$cur" ) )
+	fi
+
+    return 0
+} &&
+complete -F _debdiff debdiff
+        
+# ex: ts=4 sw=4 et filetype=sh

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list