Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added missing bin/ dir because of .gitignore

  • Loading branch information...
commit 76f044e73ef60adcdf8b6b6df3180cb653e444df 1 parent 94ae2a5
@n1k0 n1k0 authored
Showing with 60 additions and 1 deletion.
  1. +0 −1  .gitignore
  2. +60 −0 bin/onetask
View
1  .gitignore
@@ -7,7 +7,6 @@ dist
build
eggs
parts
-bin
var
sdist
develop-eggs
View
60 bin/onetask
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import argparse
+import unittest
+
+from onetask.collection import TaskCollection, TaskError
+from onetask.tests import TaskCollectionTest
+
+
+TASKS_DATABASE = os.path.expanduser('~/.OneTask.json')
+
+
+def test():
+ suite = unittest.TestLoader().loadTestsFromTestCase(TaskCollectionTest)
+ unittest.TextTestRunner(verbosity=1).run(suite)
+
+
+def get_args(args_list):
+ parser = argparse.ArgumentParser(
+ description='OneTask let you focus on one task at the time, avoiding '
+ 'discouragement by seing all the remaining work to do.')
+ subparsers = parser.add_subparsers(help='available actions')
+ add_subparser = subparsers.add_parser('add', help='add a new task')
+ add_subparser.add_argument('task', type=str, help='task message')
+ add_subparser.set_defaults(func=tasks.add)
+ get_subparser = subparsers.add_parser('get',
+ help='display currently active task')
+ get_subparser.set_defaults(func=tasks.get)
+ history_subparser = subparsers.add_parser('history',
+ help='display tasks completion history')
+ history_subparser.set_defaults(func=tasks.history)
+ done_subparser = subparsers.add_parser('done',
+ help='mark active task as done')
+ done_subparser.set_defaults(func=tasks.done)
+ skip_subparser = subparsers.add_parser('skip',
+ help='skip current active task')
+ skip_subparser.set_defaults(func=tasks.skip)
+ test_subparser = subparsers.add_parser('test',
+ help='launch test suite')
+ test_subparser.set_defaults(func=test)
+ if len(args_list) == 0:
+ return parser.print_help()
+ else:
+ return parser.parse_args(args_list)
+
+if __name__ == '__main__':
+ tasks = TaskCollection.load(TASKS_DATABASE, stdout=sys.stdout)
+ args = get_args(sys.argv[1:])
+ try:
+ if args.func == tasks.add:
+ args.func(unicode(args.task, "utf-8"))
+ else:
+ args.func()
+ except AttributeError:
+ pass
+ except TaskError, err:
+ sys.stderr.write(str(err) + "\n")
+ sys.exit(1)
Please sign in to comment.
Something went wrong with that request. Please try again.