[Bash-completion-commits] [bash-completion] 02/03: createuser: 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 7999f28f62f49caf2b736fd835152c2579c2646d
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sun Jan 18 22:07:43 2015 +0200

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

diff --git a/completions/.gitignore b/completions/.gitignore
index ae9feb6..b1f5d7f 100644
--- a/completions/.gitignore
+++ b/completions/.gitignore
@@ -28,6 +28,7 @@ composite
 conjure
 cowthink
 createdb
+createuser
 dcop
 declare
 dfutool
diff --git a/completions/Makefile.am b/completions/Makefile.am
index 6b494be..1a841d6 100644
--- a/completions/Makefile.am
+++ b/completions/Makefile.am
@@ -446,6 +446,7 @@ CLEANFILES = \
 	conjure \
 	cowthink \
 	createdb \
+	createuser \
 	dcop \
 	declare \
 	dfutool \
@@ -828,7 +829,7 @@ symlinks: $(targetdir) $(DATA)
 		rm -f $(targetdir)/$$file && \
 			$(LN_S) pm-hibernate $(targetdir)/$$file ; \
 	done
-	for file in createdb dropdb ; do \
+	for file in createdb createuser dropdb ; do \
 		rm -f $(targetdir)/$$file && \
 			$(LN_S) psql $(targetdir)/$$file ; \
 	done
diff --git a/completions/psql b/completions/psql
index a43cdaf..12dc9de 100644
--- a/completions/psql
+++ b/completions/psql
@@ -53,6 +53,36 @@ _createdb()
 } &&
 complete -F _createdb createdb
 
+# createuser(1) completion
+#
+_createuser()
+{
+    local cur prev words cword split
+    _init_completion -s || return
+
+    case $prev in
+        --help|--version|-p|--port|-c|--connection-limit)
+            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
+    fi
+} &&
+complete -F _createuser createuser
+
 # dropdb(1) completion
 #
 _dropdb()
diff --git a/test/completion/createuser.exp b/test/completion/createuser.exp
new file mode 100644
index 0000000..ad1c24c
--- /dev/null
+++ b/test/completion/createuser.exp
@@ -0,0 +1 @@
+assert_source_completions createuser
diff --git a/test/lib/completions/createuser.exp b/test/lib/completions/createuser.exp
new file mode 100644
index 0000000..87d4ac8
--- /dev/null
+++ b/test/lib/completions/createuser.exp
@@ -0,0 +1,18 @@
+proc setup {} {
+    save_env
+}
+
+
+proc teardown {} {
+    assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "createuser -"
+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