summaryrefslogtreecommitdiff
path: root/source4/scripting/bin/samba-tool
diff options
context:
space:
mode:
authorGiampaolo Lauria <lauria2@yahoo.com>2011-07-28 21:44:06 -0400
committerAndrew Bartlett <abartlet@samba.org>2011-09-09 15:24:01 +1000
commitf5e173284a959197ea3ee347fc9625aadb9591dc (patch)
treee692a1cc91f98676dd831c0565b1b52668f59c8c /source4/scripting/bin/samba-tool
parent02650acac397afe509b6b3bce6df975920d386b8 (diff)
downloadsamba-f5e173284a959197ea3ee347fc9625aadb9591dc.tar.gz
samba-f5e173284a959197ea3ee347fc9625aadb9591dc.tar.bz2
samba-f5e173284a959197ea3ee347fc9625aadb9591dc.zip
samba-tool: Redefined samba-tool as a SuperCommand
Removed MainCommand class as samba-tool is a SuperCommand Redefined samba-tool as a SuperCommand Fixed error handling in SuperCommand _run Signed-off-by: Amitay Isaacs <amitay@gmail.com> Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/scripting/bin/samba-tool')
-rwxr-xr-xsource4/scripting/bin/samba-tool36
1 files changed, 5 insertions, 31 deletions
diff --git a/source4/scripting/bin/samba-tool b/source4/scripting/bin/samba-tool
index 7d662308a2..ba792fb886 100755
--- a/source4/scripting/bin/samba-tool
+++ b/source4/scripting/bin/samba-tool
@@ -23,41 +23,15 @@ import sys
sys.path.insert(0, "bin/python")
from samba import netcmd
-from samba.netcmd import Command, CommandError
+from samba.netcmd import SuperCommand
-class MainCommand(Command):
- """Main class for samba tool commands"""
- commands = {}
+class cmd_sambatool(SuperCommand):
+ """samba-tool SuperCommand"""
+
+ subcommands = netcmd.commands
- def _run(self, myname, command=None, *args):
- if command in self.commands:
- return self.commands[command]._run(command, *args)
- print "Usage: samba-tool <command> [options]"
- print "Available commands:"
- cmds = self.commands.keys()
- cmds.sort()
- for cmd in cmds:
- print " %-16s - %s" % (cmd, self.commands[cmd].description)
- if command in [None]:
- raise CommandError("You must specify a command")
- if command in ['help', '-h', '--help']:
- print "For more help on a specific command, please type: samba-tool <command> (-h|--help)"
- return 0
- raise CommandError("No such command '%s'" % command)
-
- def usage(self, myname, command=None, *args):
- if command is None or not command in self.commands:
- print "Usage: samba-tool %s (%s) [options]" % (myname,
- " | ".join(self.commands.keys()))
- else:
- return self.commands[command].usage(*args)
-
-
-class cmd_sambatool(MainCommand):
- """Samba Tool Commands"""
- commands = netcmd.commands
if __name__ == '__main__':