summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mcrute@gmail.com>2010-02-05 18:18:48 -0500
committerMike Crute <mcrute@gmail.com>2010-02-05 18:18:48 -0500
commit827ff3b327e4dd0c0139aa833a122a3e0b9c2873 (patch)
treea3570adf89fee5e1d5f1d03a1c421b90a6cf9c35
parent641b23a4925e08534d02c6f274e6a56c729a583b (diff)
downloadkronos-827ff3b327e4dd0c0139aa833a122a3e0b9c2873.tar.bz2
kronos-827ff3b327e4dd0c0139aa833a122a3e0b9c2873.tar.xz
kronos-827ff3b327e4dd0c0139aa833a122a3e0b9c2873.zip
First pass at the command line interface.
-rw-r--r--kronos/cli.py29
-rw-r--r--kronos/tests/test_cli.py29
2 files changed, 58 insertions, 0 deletions
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 @@
1# vim: set filencoding=utf8
2"""
3Kronos Command Line UI
4
5@author: Mike Crute (mcrute@ag.com)
6@organization: American Greetings Interactive
7@date: February 05, 2010
8"""
9
10
11import sys
12from optparse import OptionParser
13from kronos.parser import parse_activity
14
15
16class CommandLineUI(object):
17
18 def __init__(self, args):
19 self.args = args
20 self.parse_args()
21
22 def parse_args(self):
23 self.action = self.args[1]
24
25 activity = ' '.join(self.args[2:])
26 self.activity = parse_activity(activity)
27
28 def run(self):
29 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 @@
1# vim: set filencoding=utf8
2"""
3Test Suite for Command Line UI
4
5@author: Mike Crute (mcrute@ag.com)
6@organization: American Greetings Interactive
7@date: February 05, 2010
8"""
9
10
11from nose.tools import assert_equals
12from kronos.cli import CommandLineUI
13from kronos.model import Activity
14
15
16class TestWhenParsingArgs(object):
17
18 def setup(self):
19 args = ['kronos', 'start', 'my action@home', '#stuff', '#good']
20 self.ui = CommandLineUI(args)
21 self.ui.run()
22
23 def test_should_identify_action(self):
24 assert_equals(self.ui.action, 'start')
25
26 def test_should_parse_action(self):
27 assert isinstance(self.ui.activity, Activity)
28 assert_equals(self.ui.activity.activity, 'my action')
29 assert_equals(self.ui.activity.category, 'home')