mirror of
git://git.proxmox.com/git/pve-storage.git
synced 2025-02-04 17:47:17 +03:00
improve bash completions
This commit is contained in:
parent
c669f42d4e
commit
f7621c0126
@ -111,12 +111,17 @@ __PACKAGE__->register_method ({
|
||||
additionalProperties => 0,
|
||||
properties => {
|
||||
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 => {
|
||||
description => "The name of the file to create.",
|
||||
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 => {
|
||||
description => "Size in kilobyte (1024 bytes). Optional suffixes 'M' (megabyte, 1024K) and 'G' (gigabyte, 1024M)",
|
||||
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;
|
||||
|
@ -20,7 +20,8 @@ cfs_register_file ('storage.cfg',
|
||||
my $defaultData = {
|
||||
propertyList => {
|
||||
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 }),
|
||||
content => {
|
||||
description => "Allowed content types. Note: value 'rootdir' is used for Containers, and value 'images' for KVM-Qemu VM's.\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user