]> git.proxmox.com Git - pve-guest-common.git/commitdiff
Bash completion helper for snapshot name
authorRhonda D'Vine <rhonda@proxmox.com>
Mon, 12 Nov 2018 13:58:48 +0000 (14:58 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Nov 2018 10:55:08 +0000 (11:55 +0100)
This is the bash completion helper function for completing the snapshot
name.  This is used both in qemu-server and pve-container.

This patch is the base for the patches in qemu-server and pve-container.

Signed-off-by: Rhonda D'Vine <rhonda@proxmox.com>
PVE/AbstractConfig.pm

index 4cfe9bc286e3c7db60a2ffff66f10089eace7b77..12086b1c95153ef68d8e78f3a2c2d0300904661a 100644 (file)
@@ -697,4 +697,17 @@ sub snapshot_rollback {
     $class->lock_config($vmid, $updatefn);
 }
 
+# bash completion helper
+
+sub complete_snapshot_name {
+    my ($class) = @_;
+    my $vmid = $_[4][0];
+
+    my $conf = $class->load_config($vmid);
+
+    my $snapshot = [ keys %{$conf->{snapshots}} ];
+
+    return $snapshot;
+}
+
 1;