[pve-devel] [pve-container cli cleanup 4/5] pct listsnapshot: use print_api_result

Dietmar Maurer dietmar at proxmox.com
Thu Aug 9 11:43:48 CEST 2018


Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 src/PVE/CLI/pct.pm | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
index 6be735f..87e15ed 100755
--- a/src/PVE/CLI/pct.pm
+++ b/src/PVE/CLI/pct.pm
@@ -788,14 +788,10 @@ our $cmddef = {
 
     listsnapshot => [ "PVE::API2::LXC::Snapshot", 'list', ['vmid'], { node => $nodename },
 		      sub {
-			  my $res = shift;
-			  foreach my $e (@$res) {
-			      my $headline = $e->{description} || 'no-description';
-			      $headline =~ s/\n.*//sg;
-			      my $parent = $e->{parent} // 'no-parent';
-			      printf("%-20s %-20s %s\n", $e->{name}, $parent, $headline);
-			  }
-		      }],
+			  my ($data, $schema, $options) = @_;
+			  my $proplist = ['name', 'snaptime', 'parent', 'description'];
+			  PVE::CLIFormatter::print_api_result($data, $schema, $proplist, $options);
+		      }, $PVE::RESTHandler::standard_output_options],
 
     rollback => [ "PVE::API2::LXC::Snapshot", 'rollback', ['vmid', 'snapname'], { node => $nodename } , $upid_exit ],
 
-- 
2.11.0




More information about the pve-devel mailing list