From 827ff3b327e4dd0c0139aa833a122a3e0b9c2873 Mon Sep 17 00:00:00 2001 From: Mike Crute Date: Fri, 5 Feb 2010 18:18:48 -0500 Subject: First pass at the command line interface. --- kronos/cli.py | 29 +++++++++++++++++++++++++++++ kronos/tests/test_cli.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 kronos/cli.py create mode 100644 kronos/tests/test_cli.py diff --git a/kronos/cli.py b/kronos/cli.py new file mode 100644 index 0000000..bdb5274 --- /dev/null +++ b/kronos/cli.py @@ -0,0 +1,29 @@ +# vim: set filencoding=utf8 +""" +Kronos Command Line UI + +@author: Mike Crute (mcrute@ag.com) +@organization: American Greetings Interactive +@date: February 05, 2010 +""" + + +import sys +from optparse import OptionParser +from kronos.parser import parse_activity + + +class CommandLineUI(object): + + def __init__(self, args): + self.args = args + self.parse_args() + + def parse_args(self): + self.action = self.args[1] + + activity = ' '.join(self.args[2:]) + self.activity = parse_activity(activity) + + def run(self): + pass diff --git a/kronos/tests/test_cli.py b/kronos/tests/test_cli.py new file mode 100644 index 0000000..c3b8e4d --- /dev/null +++ b/kronos/tests/test_cli.py @@ -0,0 +1,29 @@ +# vim: set filencoding=utf8 +""" +Test Suite for Command Line UI + +@author: Mike Crute (mcrute@ag.com) +@organization: American Greetings Interactive +@date: February 05, 2010 +""" + + +from nose.tools import assert_equals +from kronos.cli import CommandLineUI +from kronos.model import Activity + + +class TestWhenParsingArgs(object): + + def setup(self): + args = ['kronos', 'start', 'my action@home', '#stuff', '#good'] + self.ui = CommandLineUI(args) + self.ui.run() + + def test_should_identify_action(self): + assert_equals(self.ui.action, 'start') + + def test_should_parse_action(self): + assert isinstance(self.ui.activity, Activity) + assert_equals(self.ui.activity.activity, 'my action') + assert_equals(self.ui.activity.category, 'home') -- cgit v1.2.3