]> git.proxmox.com Git - pve-common.git/commitdiff
CLIHandler: add helper to generate bash completion config
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 4 Sep 2015 04:19:05 +0000 (06:19 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 4 Sep 2015 04:19:05 +0000 (06:19 +0200)
src/PVE/CLIHandler.pm

index aee6bb2a4f8de2581a763b2520709b32bd5525bc..9113c383142ae8f8844b1152f6ce8dba0a60aaa2 100644 (file)
@@ -269,6 +269,26 @@ sub verify_api {
     PVE::RESTHandler::validate_method_schemas();
 }
 
+sub generate_bash_completions {
+    my ($class) = @_;
+
+    # generate bash completion config
+
+    $exename = $class;
+    $exename =~ s/^.*:://;
+
+    print <<__EOD__;
+# $exename 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 '$exename bashcomplete' $exename
+__EOD__
+}
+
 sub generate_pod_manpage {
     my ($class, $podfn) = @_;