From 60bf020394f5006dc343a8477c7621ca00f7ce88 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 28 Nov 2010 10:52:09 +1100 Subject: [PATCH] s4-samba-tool: support help, and show description of commands when you don't specify a subcommand, show the description of the subcommands in the list of available subcommands. Also show the list of subcommands when you use 'help', '--help' or '-h' as a subcommand Autobuild-User: Andrew Tridgell Autobuild-Date: Sun Nov 28 01:56:46 CET 2010 on sn-devel-104 --- source4/scripting/python/samba/netcmd/__init__.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py index dafdd77c87f..af317ab7e04 100644 --- a/source4/scripting/python/samba/netcmd/__init__.py +++ b/source4/scripting/python/samba/netcmd/__init__.py @@ -112,14 +112,14 @@ class SuperCommand(Command): subcommands = {} def _run(self, myname, subcommand=None, *args): - if subcommand is None: - print "Available subcommands:" - for subcommand in self.subcommands: - print "\t%s" % subcommand + if subcommand in self.subcommands: + return self.subcommands[subcommand]._run(subcommand, *args) + print "Available subcommands:" + for cmd in self.subcommands: + print "\t%-20s - %s" % (cmd, self.subcommands[cmd].description) + if subcommand in [None, 'help', '-h', '--help' ]: return 0 - if not subcommand in self.subcommands: - raise CommandError("No such subcommand '%s'" % subcommand) - return self.subcommands[subcommand]._run(subcommand, *args) + raise CommandError("No such subcommand '%s'" % subcommand) def usage(self, myname, subcommand=None, *args): if subcommand is None or not subcommand in self.subcommands: -- 2.11.4.GIT