improve bash completions
This commit is contained in:
@ -111,12 +111,17 @@ __PACKAGE__->register_method ({
|
|||||||
additionalProperties => 0,
|
additionalProperties => 0,
|
||||||
properties => {
|
properties => {
|
||||||
node => get_standard_option('pve-node'),
|
node => get_standard_option('pve-node'),
|
||||||
storage => get_standard_option('pve-storage-id'),
|
storage => get_standard_option('pve-storage-id', {
|
||||||
|
completion => \&PVE::Storage::complete_storage_enabled,
|
||||||
|
}),
|
||||||
filename => {
|
filename => {
|
||||||
description => "The name of the file to create.",
|
description => "The name of the file to create.",
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
vmid => get_standard_option('pve-vmid', { description => "Specify owner VM" } ),
|
vmid => get_standard_option('pve-vmid', {
|
||||||
|
description => "Specify owner VM",
|
||||||
|
completion => \&PVE::Cluster::complete_vmid,
|
||||||
|
}),
|
||||||
size => {
|
size => {
|
||||||
description => "Size in kilobyte (1024 bytes). Optional suffixes 'M' (megabyte, 1024K) and 'G' (gigabyte, 1024M)",
|
description => "Size in kilobyte (1024 bytes). Optional suffixes 'M' (megabyte, 1024K) and 'G' (gigabyte, 1024M)",
|
||||||
type => 'string',
|
type => 'string',
|
||||||
|
|||||||
@ -1167,4 +1167,25 @@ sub foreach_volid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# bash completion helper
|
||||||
|
|
||||||
|
sub complete_storage {
|
||||||
|
my ($cmdname, $pname, $cvalue) = @_;
|
||||||
|
|
||||||
|
return $cmdname eq 'add' ? [] : [ PVE::Storage::storage_ids() ];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub complete_storage_enabled {
|
||||||
|
my ($cmdname, $pname, $cvalue) = @_;
|
||||||
|
|
||||||
|
my $res = [];
|
||||||
|
|
||||||
|
my $cfg = PVE::Storage::config();
|
||||||
|
foreach my $sid (keys %{$cfg->{ids}}) {
|
||||||
|
next if !storage_check_enabled($cfg, $sid, undef, 1);
|
||||||
|
push @$res, $sid;
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@ -20,7 +20,8 @@ cfs_register_file ('storage.cfg',
|
|||||||
my $defaultData = {
|
my $defaultData = {
|
||||||
propertyList => {
|
propertyList => {
|
||||||
type => { description => "Storage type." },
|
type => { description => "Storage type." },
|
||||||
storage => get_standard_option('pve-storage-id'),
|
storage => get_standard_option('pve-storage-id',
|
||||||
|
{ completion => \&PVE::Storage::complete_storage }),
|
||||||
nodes => get_standard_option('pve-node-list', { optional => 1 }),
|
nodes => get_standard_option('pve-node-list', { optional => 1 }),
|
||||||
content => {
|
content => {
|
||||||
description => "Allowed content types. Note: value 'rootdir' is used for Containers, and value 'images' for KVM-Qemu VM's.\n",
|
description => "Allowed content types. Note: value 'rootdir' is used for Containers, and value 'images' for KVM-Qemu VM's.\n",
|
||||||
|
|||||||
Reference in New Issue
Block a user