Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added missing bin/ dir because of .gitignore

  • Loading branch information...
commit 76f044e73ef60adcdf8b6b6df3180cb653e444df 1 parent 94ae2a5
Nicolas Perriault authored October 07, 2012

Showing 2 changed files with 60 additions and 1 deletion. Show diff stats Hide diff stats

  1. 1  .gitignore
  2. 60  bin/onetask
1  .gitignore
@@ -7,7 +7,6 @@ dist
7 7
 build
8 8
 eggs
9 9
 parts
10  
-bin
11 10
 var
12 11
 sdist
13 12
 develop-eggs
60  bin/onetask
... ...
@@ -0,0 +1,60 @@
  1
+#!/usr/bin/env python
  2
+
  3
+import os
  4
+import sys
  5
+import argparse
  6
+import unittest
  7
+
  8
+from onetask.collection import TaskCollection, TaskError
  9
+from onetask.tests import TaskCollectionTest
  10
+
  11
+
  12
+TASKS_DATABASE = os.path.expanduser('~/.OneTask.json')
  13
+
  14
+
  15
+def test():
  16
+    suite = unittest.TestLoader().loadTestsFromTestCase(TaskCollectionTest)
  17
+    unittest.TextTestRunner(verbosity=1).run(suite)
  18
+
  19
+
  20
+def get_args(args_list):
  21
+    parser = argparse.ArgumentParser(
  22
+        description='OneTask let you focus on one task at the time, avoiding '
  23
+                    'discouragement by seing all the remaining work to do.')
  24
+    subparsers = parser.add_subparsers(help='available actions')
  25
+    add_subparser = subparsers.add_parser('add', help='add a new task')
  26
+    add_subparser.add_argument('task', type=str, help='task message')
  27
+    add_subparser.set_defaults(func=tasks.add)
  28
+    get_subparser = subparsers.add_parser('get',
  29
+        help='display currently active task')
  30
+    get_subparser.set_defaults(func=tasks.get)
  31
+    history_subparser = subparsers.add_parser('history',
  32
+        help='display tasks completion history')
  33
+    history_subparser.set_defaults(func=tasks.history)
  34
+    done_subparser = subparsers.add_parser('done',
  35
+        help='mark active task as done')
  36
+    done_subparser.set_defaults(func=tasks.done)
  37
+    skip_subparser = subparsers.add_parser('skip',
  38
+        help='skip current active task')
  39
+    skip_subparser.set_defaults(func=tasks.skip)
  40
+    test_subparser = subparsers.add_parser('test',
  41
+        help='launch test suite')
  42
+    test_subparser.set_defaults(func=test)
  43
+    if len(args_list) == 0:
  44
+        return parser.print_help()
  45
+    else:
  46
+        return parser.parse_args(args_list)
  47
+
  48
+if __name__ == '__main__':
  49
+    tasks = TaskCollection.load(TASKS_DATABASE, stdout=sys.stdout)
  50
+    args = get_args(sys.argv[1:])
  51
+    try:
  52
+        if args.func == tasks.add:
  53
+            args.func(unicode(args.task, "utf-8"))
  54
+        else:
  55
+            args.func()
  56
+    except AttributeError:
  57
+        pass
  58
+    except TaskError, err:
  59
+        sys.stderr.write(str(err) + "\n")
  60
+        sys.exit(1)

0 notes on commit 76f044e

Please sign in to comment.
Something went wrong with that request. Please try again.