filled out Command.parseCommandLine()

This commit is contained in:
Josh Holtrop 2010-12-11 09:55:07 -05:00
parent 3af40dc453
commit 70f57c4ce7

View File

@ -1,4 +1,6 @@
from datetime import datetime
class Command: class Command:
def __init__(self, timenow, cmdline): def __init__(self, timenow, cmdline):
self.time = timenow self.time = timenow
@ -6,4 +8,29 @@ class Command:
self.parseCommandLine(cmdline) self.parseCommandLine(cmdline)
def parseCommandLine(self, cmdline): def parseCommandLine(self, cmdline):
COMMANDS = {
'out' : 1,
'report' : 1,
'show' : 1,
'fill' : 1,
'adjust' : 1
}
parts = cmdline.split(None, 1) parts = cmdline.split(None, 1)
if len(parts) > 1:
timespec = parts[0].strip()
if timespec[0] == '@':
self.time = self.parseTimeSpec(timespec[1:])
parts = parts[1:]
if len(parts) == 1:
command = parts[0].strip()
rest = ''
else:
command, rest = parts
if command in COMMANDS:
self.command = command
self.argstr = rest.strip()
else:
self.argstr = ' '.join([command, rest]).strip()
def parseTimeSpec(self, timespec):
pass