use PVE::APIClient::Tools qw(extract_param);
use PVE::APIClient::Config;
+use PVE::APIClient::CLIFormatter;
use PVE::APIClient::CLIHandler;
use base qw(PVE::APIClient::CLIHandler);
description => "Dump default configuration.",
parameters => {
additionalProperties => 0,
+ properties => {},
},
returns => {
type => 'object',
our $cmddef = {
set => [ __PACKAGE__, 'set',],
- list => [__PACKAGE__, 'list', undef, undef, sub { PVE::APIClient::Helpers::print_result(@_);}],
+ list => [__PACKAGE__, 'list', undef, undef,
+ sub {
+ my ($data, $schema, $options) = @_;
+
+ PVE::APIClient::CLIFormatter::print_api_result($data, $schema, undef, $options);
+ }
+ ],
};
1;
additionalProperties => 0,
properties => {
remote => get_standard_option('pveclient-remote-name'),
- 'format' => get_standard_option('pve-output-format'),
},
},
returns => {
code => sub {
my ($param) = @_;
- my $format = PVE::APIClient::Tools::extract_param($param, 'format');
- PVE::APIClient::Helpers::set_output_format($format);
-
my $config = PVE::APIClient::Config->load();
my $conn = PVE::APIClient::Config->remote_conn($config, $param->{remote});
our $cmddef = [ __PACKAGE__, 'list', ['remote'], {}, sub {
- PVE::APIClient::Helpers::print_ordered_result($list_returns_properties, @_);
+ my ($data, $schema, $options) = @_;
+ PVE::APIClient::Helpers::print_ordered_result($list_returns_properties, $data, $schema, $options);
}];
1;
description => "List remotes from your config file.",
parameters => {
additionalProperties => 0,
- properties => {
- 'format' => get_standard_option('pve-output-format'),
- },
+ properties => {},
},
returns => {
type => 'array',
code => sub {
my ($param) = @_;
- my $format = PVE::APIClient::Tools::extract_param($param, 'format');
- PVE::APIClient::Helpers::set_output_format($format);
-
my $config = PVE::APIClient::Config->load();
my $res = [];
set => [ __PACKAGE__, 'remote_set', ['name']],
delete => [ __PACKAGE__, 'remote_delete', ['name']],
list => [__PACKAGE__, 'remote_list', undef, {}, sub {
- PVE::APIClient::Helpers::print_ordered_result($remote_list_returns_properties, @_);
+ my ($data, $schema, $options) = @_;
+ PVE::APIClient::Helpers::print_ordered_result($remote_list_returns_properties, $data, $schema, $options);
}],
};
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) = @_;
return [ grep { ($ind++ % 2) == 0 } @$list ];
}
-sub print_result {
- my ($data, $result_schema, $param_order) = @_;
-
- my $options = {};
- PVE::APIClient::CLIFormatter::query_terminal_options($options);
-
- my $format = get_output_format();
- PVE::APIClient::CLIFormatter::print_api_result(
- $format, $data, $result_schema, $param_order, $options);
-}
-
sub print_ordered_result {
- my ($property_list, $data, $result_schema) = @_;
+ my ($property_list, $data, $result_schema, $options) = @_;
my $param_order = extract_even_elements($property_list);
- print_result($data, $result_schema, $param_order);
+ PVE::APIClient::CLIFormatter::print_api_result($data, $result_schema, $param_order, $options);
}
1;
use JSON;
sub call_api_method {
- my ($method, $param) = @_;
+ my ($method, $param, $options) = @_;
my $path = PVE::APIClient::Tools::extract_param($param, 'api_path');
die "missing API path\n" if !defined($path);
my $remote = PVE::APIClient::Tools::extract_param($param, 'remote');
die "missing remote\n" if !defined($remote);
- my $format = PVE::APIClient::Tools::extract_param($param, 'format');
- PVE::APIClient::Helpers::set_output_format($format);
-
my $config = PVE::APIClient::Config->load();
my $uri_param = {};
$path_returns = $info->{returns};
}
-$path_properties->{format} = get_standard_option('pve-output-format'),
$path_properties->{remote} = get_standard_option('pveclient-remote-name');
$path_properties->{api_path} = $api_path_property;
my $format_result = sub {
- my ($data) = @_;
-
- my $format = PVE::APIClient::Helpers::get_output_format();
+ my ($data, $schema, $options) = @_;
- my $options = PVE::APIClient::CLIFormatter::query_terminal_options({});
-
- PVE::APIClient::CLIFormatter::print_api_result($format, $data, $path_returns, undef, $options);
+ # NOTE; we need to use $path_returns instead of $schema
+ PVE::APIClient::CLIFormatter::print_api_result($data, $path_returns, undef, $options);
};
__PACKAGE__->register_method ({
},
returns => $path_returns,
code => sub {
- my ($param) = @_;
+ my ($param, $options) = @_;
- return call_api_method('GET', $param);
+ return call_api_method('GET', $param, $options);
}});
__PACKAGE__->register_method ({
},
returns => $path_returns,
code => sub {
- my ($param) = @_;
+ my ($param, $options) = @_;
- return call_api_method('PUT', $param);
+ return call_api_method('PUT', $param, $options);
}});
__PACKAGE__->register_method ({
},
returns => $path_returns,
code => sub {
- my ($param) = @_;
+ my ($param, $options) = @_;
- return call_api_method('PUSH', $param);
+ return call_api_method('PUSH', $param, $options);
}});
__PACKAGE__->register_method ({
},
returns => $path_returns,
code => sub {
- my ($param) = @_;
+ my ($param, $options) = @_;
- return call_api_method('DELETE', $param);
+ return call_api_method('DELETE', $param, $options);
}});
__PACKAGE__->register_method ({