X-Git-Url: https://git.proxmox.com/?p=pve-client.git;a=blobdiff_plain;f=PVE%2FAPIClient%2FHelpers.pm;h=7e4447dd8ab6c9b3a070ec4cedf810dd7bb97e21;hp=1503ec0c90428ee08ec63e4cb2e8005b2faaae1c;hb=a00bef992d68c429798d031ecd6dec7935cb381b;hpb=6f6263a7ddefe1e686b7787c908b40477c48a93e diff --git a/PVE/APIClient/Helpers.pm b/PVE/APIClient/Helpers.pm index 1503ec0..7e4447d 100644 --- a/PVE/APIClient/Helpers.pm +++ b/PVE/APIClient/Helpers.pm @@ -20,30 +20,13 @@ my $pve_api_definition; my $pve_api_definition_fn = "/usr/share/pve-client/pve-api-definition.dat"; -my $method_map = { +our $method_map = { create => 'POST', set => 'PUT', get => 'GET', delete => 'DELETE', }; -my $default_output_format = 'text'; -my $client_output_format = $default_output_format; - -sub set_output_format { - my ($format) = @_; - - if (!defined($format)) { - $client_output_format = $default_output_format; - } else { - $client_output_format = $format; - } -} - -sub get_output_format { - return $client_output_format; -} - my $__real_remove_formats; $__real_remove_formats = sub { my ($properties) = @_; @@ -220,21 +203,20 @@ sub complete_api_path { if (my $children = $info->{children}) { foreach my $c (@$children) { my $ctext = $c->{text}; + push @$res, "${prefix}$ctext" if $ctext =~ m/^\Q$rest/; if ($ctext =~ m/^\{(\S+)\}$/) { - push @$res, "$prefix$ctext"; - push @$res, "$prefix$ctext/"; - if (length($rest)) { + if (length($rest) && $rest ne $ctext) { push @$res, "$prefix$rest"; - push @$res, "$prefix$rest/"; } - } elsif ($ctext =~ m/^\Q$rest/) { - push @$res, "$prefix$ctext"; - push @$res, "$prefix$ctext/" if $c->{children}; } } } } + if (scalar(@$res) == 1) { + $res = [$res->[0], "$res->[0]/"]; + } + return $res; } @@ -406,15 +388,11 @@ sub extract_even_elements { } sub print_ordered_result { - my ($property_list, $data, $result_schema) = @_; + my ($property_list, $data, $result_schema, $options) = @_; - my $format = get_output_format(); my $param_order = extract_even_elements($property_list); - my $options = {}; - PVE::APIClient::CLIFormatter::query_terminal_options($options); - - PVE::APIClient::CLIFormatter::print_api_result($format, $data, $result_schema, $param_order, $options); + PVE::APIClient::CLIFormatter::print_api_result($data, $result_schema, $param_order, $options); } 1;