samba-tool: Formatted subcommand list output
authorGiampaolo Lauria <lauria2@yahoo.com>
Mon, 1 Aug 2011 21:47:31 +0000 (17:47 -0400)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 9 Sep 2011 05:24:01 +0000 (15:24 +1000)
Formatted output of subcommand list to be a function of the
max number of chars in the longest string

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source4/scripting/python/samba/netcmd/__init__.py

index a4a3397d80e53247e7ca2bd962e430faee18044a..3b7b982459d4f2d5c9a8ef2b722d575780ff6281 100644 (file)
@@ -162,8 +162,9 @@ class SuperCommand(Command):
         print "Available subcommands:"
         subcmds = self.subcommands.keys()
         subcmds.sort()
+        max_length = len(max(subcmds, key=len))
         for cmd in subcmds:
-            print "    %-20s - %s" % (cmd, self.subcommands[cmd].description)
+            print "  %*s  - %s" % (-max_length, cmd, self.subcommands[cmd].description)
         if subcommand in [None]:
             raise CommandError("You must specify a subcommand")
         if subcommand in ['help', '-h', '--help']: