filled out Command.parseCommandLine()
This commit is contained in:
parent
3af40dc453
commit
70f57c4ce7
27
Command.py
27
Command.py
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user