subcommands

This commit is contained in:
Michael Murtaugh
2015-09-17 18:23:18 +02:00
parent 94444a5d4d
commit 298cc2a8fe
7 changed files with 434 additions and 415 deletions
+17 -2
View File
@@ -1,7 +1,22 @@
#!/usr/bin/env python
from etherdump import main
import sys
main()
try:
cmd = sys.argv[1]
if cmd.startswith("-"):
cmd = "dump"
args = sys.argv
else:
args = sys.argv[2:]
except IndexError:
cmd = "dump"
args = sys.argv[1:]
try:
# http://stackoverflow.com/questions/301134/dynamic-module-import-in-python
cmdmod = __import__("etherdump.commands.%s" % cmd, fromlist=["etherdump.commands"])
cmdmod.main(args)
except ImportError, e:
print "Command '{0}' not available ({1})".format(cmd, e)