From d4c1149e3ec11a59cb49cd9be71079e503eb9e19 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Thu, 21 Jul 2011 12:15:33 +1000 Subject: [PATCH] samba-tool: Display Usage line and list commands alphabetically Signed-off-by: Andrew Tridgell --- source4/scripting/python/samba/netcmd/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py index 3e8d274b7e8..316a819053c 100644 --- a/source4/scripting/python/samba/netcmd/__init__.py +++ b/source4/scripting/python/samba/netcmd/__init__.py @@ -157,9 +157,12 @@ class SuperCommand(Command): def _run(self, myname, subcommand=None, *args): if subcommand in self.subcommands: return self.subcommands[subcommand]._run(subcommand, *args) + print "Usage: samba-tool %s [options]" % myname print "Available subcommands:" - for cmd in self.subcommands: - print "\t%-20s - %s" % (cmd, self.subcommands[cmd].description) + subcmds = self.subcommands.keys() + subcmds.sort() + for cmd in subcmds: + print " %-20s - %s" % (cmd, self.subcommands[cmd].description) if subcommand in [None]: self.show_command_error("You must specify a subcommand") return -1 @@ -176,7 +179,7 @@ class SuperCommand(Command): def usage(self, myname, subcommand=None, *args): if subcommand is None or not subcommand in self.subcommands: - print "Usage: %s (%s) [options]" % (myname, + print "Usage: samba-tool %s (%s) [options]" % (myname, " | ".join(self.subcommands.keys())) else: return self.subcommands[subcommand].usage(*args)