[Bash-completion-commits] [bash-completion] 03/03: dropuser: New completion

Ville Skyttä scop-guest at moszumanska.debian.org
Sun Jan 18 20:15:47 UTC 2015


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

scop-guest pushed a commit to branch master
in repository bash-completion.

commit 3cf50a1437f9f0b8ef16bd6ea58db18e7a9204f6
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sun Jan 18 22:11:19 2015 +0200

    dropuser: New completion
---
 completions/.gitignore            |  1 +
 completions/Makefile.am           |  3 ++-
 completions/psql                  | 32 ++++++++++++++++++++++++++++++++
 test/completion/dropuser.exp      |  1 +
 test/lib/completions/dropuser.exp | 18 ++++++++++++++++++
 5 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/completions/.gitignore b/completions/.gitignore
index b1f5d7f..31567f7 100644
--- a/completions/.gitignore
+++ b/completions/.gitignore
@@ -37,6 +37,7 @@ dpkg-deb
 dpkg-query
 dpkg-reconfigure
 dropdb
+dropuser
 edquota
 f77
 f95
diff --git a/completions/Makefile.am b/completions/Makefile.am
index 1a841d6..8b5e7f2 100644
--- a/completions/Makefile.am
+++ b/completions/Makefile.am
@@ -455,6 +455,7 @@ CLEANFILES = \
 	dpkg-query \
 	dpkg-reconfigure \
 	dropdb \
+	dropuser \
 	edquota \
 	f77 \
 	f95 \
@@ -829,7 +830,7 @@ symlinks: $(targetdir) $(DATA)
 		rm -f $(targetdir)/$$file && \
 			$(LN_S) pm-hibernate $(targetdir)/$$file ; \
 	done
-	for file in createdb createuser dropdb ; do \
+	for file in createdb createuser dropdb dropuser ; do \
 		rm -f $(targetdir)/$$file && \
 			$(LN_S) psql $(targetdir)/$$file ; \
 	done
diff --git a/completions/psql b/completions/psql
index 12dc9de..a111052 100644
--- a/completions/psql
+++ b/completions/psql
@@ -116,6 +116,38 @@ _dropdb()
 } &&
 complete -F _dropdb dropdb
 
+# dropuser(1) completion
+#
+_dropuser()
+{
+    local cur prev words cword split
+    _init_completion -s || return
+
+    case $prev in
+        --help|--version|-p|--port)
+            return
+            ;;
+        -h|--host)
+            _known_hosts_real "$cur"
+            return
+            ;;
+        -U|--username)
+            _pg_users
+            return
+            ;;
+    esac
+
+    $split && return
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+        [[ $COMPREPLY == *= ]] && compopt -o nospace
+    else
+        _pg_users
+    fi
+} &&
+complete -F _dropuser dropuser
+
 # psql(1) completion
 #
 _psql()
diff --git a/test/completion/dropuser.exp b/test/completion/dropuser.exp
new file mode 100644
index 0000000..1be7988
--- /dev/null
+++ b/test/completion/dropuser.exp
@@ -0,0 +1 @@
+assert_source_completions dropuser
diff --git a/test/lib/completions/dropuser.exp b/test/lib/completions/dropuser.exp
new file mode 100644
index 0000000..8b36fa5
--- /dev/null
+++ b/test/lib/completions/dropuser.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+    save_env
+}
+
+
+proc teardown {} {
+    assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "dropuser "
+sync_after_int
+
+
+teardown

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/bash-completion/bash-completion.git



More information about the Bash-completion-commits mailing list