From 558be2e57a38dc82b9d0b453d8b5871b25142f87 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 2 Sep 2015 15:29:54 +0200 Subject: [PATCH] vzdump: add bash completion support --- bin/Makefile | 4 +++- bin/vzdump | 2 +- bin/vzdump.bash-completion | 8 ++++++++ defines.mk | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 bin/vzdump.bash-completion diff --git a/bin/Makefile b/bin/Makefile index fb8e89ae..37d3a422 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -70,7 +70,8 @@ pvemailforward: pvemailforward.c gcc $< -o $@ -g -O2 -Wall -ldl -lc .PHONY: install -install: ${SCRIPTS} ${MANS} pvemailforward +install: ${SCRIPTS} ${MANS} pvemailforward vzdump.bash-completion + perl -I.. ./pvesh verifyapi install -d ${BINDIR} install -m 0755 ${SCRIPTS} ${BINDIR} @@ -80,6 +81,7 @@ install: ${SCRIPTS} ${MANS} pvemailforward install -d ${PODDIR} install -m 0644 vzdump.1.pod ${PODDIR} install -m 0644 pvesubscription.1.pod ${PODDIR} + install -m 0644 -D vzdump.bash-completion ${BASHCOMPLDIR}/vzdump set -e && for i in ${SUBDIRS}; do ${MAKE} -C $$i $@; done .PHONY: distclean diff --git a/bin/vzdump b/bin/vzdump index 8e4c346c..fe8d7316 100755 --- a/bin/vzdump +++ b/bin/vzdump @@ -26,7 +26,7 @@ $rpcenv->set_language($ENV{LANG}); $rpcenv->set_user('root@pam'); -my $cmddef = [ 'PVE::API2::VZDump', 'vzdump', 'vmid', undef, +my $cmddef = [ 'PVE::API2::VZDump', 'vzdump', ['vmid'], undef, sub { my $upid = shift; exit(0) if $upid eq 'OK'; diff --git a/bin/vzdump.bash-completion b/bin/vzdump.bash-completion new file mode 100644 index 00000000..14b2bd4c --- /dev/null +++ b/bin/vzdump.bash-completion @@ -0,0 +1,8 @@ +# vzdump bash completion + +# see http://tiswww.case.edu/php/chet/bash/FAQ +# and __ltrim_colon_completions() in /usr/share/bash-completion/bash_completion +# this modifies global var, but I found no better way +COMP_WORDBREAKS=${COMP_WORDBREAKS//:} + +complete -C 'vzdump bashcomplete' vzdump diff --git a/defines.mk b/defines.mk index f7de1cba..a16251df 100644 --- a/defines.mk +++ b/defines.mk @@ -10,6 +10,7 @@ MAN1DIR=${DESTDIR}/usr/share/man/man1 CRONDAILYDIR=${DESTDIR}/etc/cron.daily INITDBINDIR=${DESTDIR}/etc/init.d SERVICEDIR=${DESTDIR}/lib/systemd/system +BASHCOMPLDIR=${DESTDIR}/usr/share/bash-completion/completions/ HARADIR=${DESTDIR}/usr/share/cluster DOCDIR=${DESTDIR}/usr/share/doc/${PACKAGE} PODDIR=${DESTDIR}/usr/share/doc/${PACKAGE}/pod