Skip to content

Commit

Permalink
Started command line interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothar Braun committed Dec 7, 2011
1 parent a892cdc commit ec5c48e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import input
import sequences
import cli
21 changes: 21 additions & 0 deletions common/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# vim: set sts=4 sw=4 cindent nowrap expandtab:

import cmd, sys

class CommandLineInterface(cmd.Cmd):
def __init__(self):
cmd.Cmd.__init__(self)
self.prompt = "inf> "

def do_EOF(self, string):
print string
sys.exit(0)

def do_quit(self, string):
sys.exit(0)

def do_exit(self, string):
sys.exit(0)

def do_help(self, string):
print string
9 changes: 8 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
import sys, getopt, yaml

def main():
# go into command line mode if no arguments are given
if len(sys.argv) == 1:
command_line_interface()
sys.exit(0)

# Defaults
format = "pcap"
Expand Down Expand Up @@ -146,7 +150,10 @@ def parseConfig(f):
except Exception as e:
print "Could not parse config file \"%s\": %s" % (f, e)
sys.exit(-1)


def command_line_interface():
cmdline = common.cli.CommandLineInterface()
cmdline.cmdloop()

if __name__ == "__main__":
main()
Expand Down

0 comments on commit ec5c48e

Please sign in to comment.