[pve-devel] r5117 - pve-common/trunk

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Sep 10 16:36:37 CEST 2010


Author: dietmar
Date: 2010-09-10 14:36:37 +0000 (Fri, 10 Sep 2010)
New Revision: 5117

Modified:
   pve-common/trunk/CLIHandler.pm
   pve-common/trunk/ChangeLog
Log:
CLIHandler.pm (print_usage_short): group command by class



Modified: pve-common/trunk/CLIHandler.pm
===================================================================
--- pve-common/trunk/CLIHandler.pm	2010-09-10 13:25:58 UTC (rev 5116)
+++ pve-common/trunk/CLIHandler.pm	2010-09-10 14:36:37 UTC (rev 5117)
@@ -79,6 +79,11 @@
 	print "$str\n\n";
     }
 }
+
+sub sorted_commands {   
+    return sort { ($cmddef->{$a}->[0] cmp $cmddef->{$b}->[0]) || ($a cmp $b)} keys %$cmddef;
+}
+
 sub print_usage_short {
     my ($fd, $msg) = @_;
 
@@ -87,10 +92,13 @@
     print $fd "ERROR: $msg\n" if $msg;
     print $fd "USAGE: $exename <COMMAND> [ARGS] [OPTIONS]\n";
 
-    foreach my $cmd (sort keys %$cmddef) {
+    my $oldclass;
+    foreach my $cmd (sorted_commands()) {
 	my ($class, $name, $arg_param, $uri_param) = @{$cmddef->{$cmd}};
 	my $str = $class->usage_str($name, "$exename $cmd", $arg_param, $uri_param, 'short');
+	print $fd "\n" if $oldclass && $oldclass ne $class;
 	print $fd "       $str";
+	$oldclass = $class;
     }
 }
 

Modified: pve-common/trunk/ChangeLog
===================================================================
--- pve-common/trunk/ChangeLog	2010-09-10 13:25:58 UTC (rev 5116)
+++ pve-common/trunk/ChangeLog	2010-09-10 14:36:37 UTC (rev 5117)
@@ -1,5 +1,7 @@
 2010-09-10  Proxmox Support Team  <support at proxmox.com>
 
+	* CLIHandler.pm (print_usage_short): group command by class
+
 	* JSONSchema.pm (register_standard_option, get_standard_option): a
 	way to register/get commom schemas by name.
 




More information about the pve-devel mailing list