From 3cf50a1437f9f0b8ef16bd6ea58db18e7a9204f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 18 Jan 2015 22:11:19 +0200 Subject: [PATCH] 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(-) create mode 100644 test/completion/dropuser.exp create mode 100644 test/lib/completions/dropuser.exp diff --git a/completions/.gitignore b/completions/.gitignore index b1f5d7f7..31567f74 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 1a841d6b..8b5e7f23 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 12dc9de4..a1110526 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 00000000..1be7988a --- /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 00000000..8b36fa5e --- /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