]> git.proxmox.com Git - pve-client.git/blobdiff - PVE/APIClient/RESTHandler.pm
update files from pve-common
[pve-client.git] / PVE / APIClient / RESTHandler.pm
index a93ba26372195beb3c6a393bb671f4b3d7141619..22e81691f3fc2e3f2ea599c579ce5444af0c9203 100644 (file)
@@ -566,7 +566,7 @@ my $compute_param_mapping_hash = sub {
 
 # generate usage information for command line tools
 #
-# $name        ... the name of the method
+# $info        ... method info
 # $prefix      ... usually something like "$exename $cmd" ('pvesm add')
 # $arg_param   ... list of parameters we want to get as ordered arguments 
 #                  on the command line (or single parameter name for lists)
@@ -577,13 +577,13 @@ my $compute_param_mapping_hash = sub {
 #   'full'     ... text, include description
 #   'asciidoc' ... generate asciidoc for man pages (like 'full')
 # $param_cb ... mapping for string parameters to file path parameters
-sub usage_str {
-    my ($self, $name, $prefix, $arg_param, $fixed_param, $format, $param_cb) = @_;
+sub getopt_usage {
+    my ($info, $prefix, $arg_param, $fixed_param, $format, $param_cb) = @_;
 
     $format = 'long' if !$format;
 
-    my $info = $self->map_method_by_name($name);
     my $schema = $info->{parameters};
+    my $name = $info->{name};
     my $prop = $schema->{properties};
 
     my $out = '';
@@ -679,6 +679,14 @@ sub usage_str {
     return $out;
 }
 
+sub usage_str {
+    my ($self, $name, $prefix, $arg_param, $fixed_param, $format, $param_cb) = @_;
+
+    my $info = $self->map_method_by_name($name);
+
+    return getopt_usage($info, $prefix, $arg_param, $fixed_param, $format, $param_cb);
+}
+
 # generate docs from JSON schema properties
 sub dump_properties {
     my ($prop, $format, $style, $filterFn) = @_;