mirror of
https://git.proxmox.com/git/pve-client
synced 2025-10-04 17:21:28 +00:00
add simple bash completion code
This commit is contained in:
parent
adf285bf0d
commit
dce6ecbc50
3
Makefile
3
Makefile
@ -8,6 +8,7 @@ DESTDIR=
|
|||||||
|
|
||||||
LIB_DIR=${DESTDIR}/usr/share/${PACKAGE}
|
LIB_DIR=${DESTDIR}/usr/share/${PACKAGE}
|
||||||
DOCDIR=${DESTDIR}/usr/share/doc/${PACKAGE}
|
DOCDIR=${DESTDIR}/usr/share/doc/${PACKAGE}
|
||||||
|
BASHCOMPLDIR=${DESTDIR}/usr/share/bash-completion/completions/
|
||||||
|
|
||||||
all: ${DEB}
|
all: ${DEB}
|
||||||
|
|
||||||
@ -34,6 +35,8 @@ install: pve-api-definition.js
|
|||||||
install -D -m 0644 PVE/APIClient/Commands/lxc.pm ${LIB_DIR}/PVE/APIClient/Commands/lxc.pm
|
install -D -m 0644 PVE/APIClient/Commands/lxc.pm ${LIB_DIR}/PVE/APIClient/Commands/lxc.pm
|
||||||
install -D -m 0644 pve-api-definition.js ${LIB_DIR}/pve-api-definition.js
|
install -D -m 0644 pve-api-definition.js ${LIB_DIR}/pve-api-definition.js
|
||||||
install -D -m 0755 pveclient ${DESTDIR}/usr/bin/pveclient
|
install -D -m 0755 pveclient ${DESTDIR}/usr/bin/pveclient
|
||||||
|
install -D -m 0644 pveclient.bash-completion ${BASHCOMPLDIR}/pveclient.bash-completion
|
||||||
|
|
||||||
|
|
||||||
pve-api-definition.js:
|
pve-api-definition.js:
|
||||||
./extractapi.pl > pve-api-definition.js.tmp
|
./extractapi.pl > pve-api-definition.js.tmp
|
||||||
|
1
debian/install
vendored
1
debian/install
vendored
@ -1,2 +1,3 @@
|
|||||||
/usr/share
|
/usr/share
|
||||||
/usr/bin
|
/usr/bin
|
||||||
|
/usr/share/bash-completion/completions
|
||||||
|
15
pveclient
15
pveclient
@ -80,6 +80,21 @@ if ($cmd eq 'get') {
|
|||||||
PVE::APIClient::Commands::lxc->run_cli_handler();
|
PVE::APIClient::Commands::lxc->run_cli_handler();
|
||||||
} elsif ($cmd eq 'remote') {
|
} elsif ($cmd eq 'remote') {
|
||||||
PVE::APIClient::Commands::remote->run_cli_handler();
|
PVE::APIClient::Commands::remote->run_cli_handler();
|
||||||
|
} elsif ($cmd eq 'bashcomplete') {
|
||||||
|
|
||||||
|
my $cmdline = substr($ENV{COMP_LINE}, 0, $ENV{COMP_POINT});
|
||||||
|
$cmdline =~ s/$cur$//;
|
||||||
|
|
||||||
|
my ($bash_command, $cur, $prev) = @ARGV;
|
||||||
|
|
||||||
|
my $args = [split(/\s+/, $cmdline)];
|
||||||
|
|
||||||
|
if (scalar(@$args) == 1) {
|
||||||
|
foreach my $p (qw(get set create delete lxc remote)) {
|
||||||
|
print "$p\n" if $p =~ m/^$cur/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
print_usage();
|
print_usage();
|
||||||
}
|
}
|
||||||
|
8
pveclient.bash-completion
Normal file
8
pveclient.bash-completion
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# pveclient 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 'pveclient bashcomplete' pveclient
|
Loading…
Reference in New Issue
Block a user