Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First commit

  • Loading branch information...
commit 42810e6eb99ff539aa787d178883aa8e5f7d4d1c 1 parent 36edbfb
@Lothiraldan authored
Showing with 112 additions and 0 deletions.
  1. +7 −0 LICENSE
  2. +27 −0 README.rst
  3. +68 −0 onetask
  4. +10 −0 setup.py
View
7 LICENSE
@@ -0,0 +1,7 @@
+Copyright © 2012 FELD Boris
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
27 README.rst
@@ -0,0 +1,27 @@
+OneTask: Manage task, one task at the time
+==========================================
+
+**OneTask** let you focus on one task at the time, avoiding discouragement by seing all the remaining work to do.
+
+QuickStart
+----------
+
+- Add a task::
+
+ $> onetask add 'Create onetask'
+ Task added
+
+- Get a random task::
+
+ $> onetask get
+ Create onetask
+
+If you try to get another task, you will get the same one.
+
+- Mark current task as done::
+
+ $> onetask done
+ Task is marked as done
+
+ $> onetask get
+ No task
View
68 onetask
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+import sys
+import argparse
+from time import time
+from pymongo import Connection
+
+collection = Connection()['onetask']['onetask']
+
+# Commands
+
+
+def add(task):
+ collection.save({'message': task})
+ print "Task added"
+
+
+def get():
+ selected_task = collection.find_one({'selected': True,
+ 'done': {'$exists': False}})
+
+ if not selected_task:
+ selected_task = collection.find_one({'done': {'$exists': False}})
+
+ if not selected_task:
+ print 'No task'
+ return
+ selected_task['selected'] = True
+ collection.save(selected_task)
+
+ print selected_task['message']
+
+
+def done():
+ selected_task = collection.find_one({'selected': True,
+ 'done': {'$exists': False}})
+
+ if not selected_task:
+ print 'No task choosed'
+ return
+
+ collection.update({'_id': selected_task['_id']},
+ {'$set': {'done': int(time())},
+ '$unset': {'selected': 1}})
+ print "Task is marked as done"
+
+# Parser
+
+parser = argparse.ArgumentParser(description='OneTask cli.')
+
+subparsers = parser.add_subparsers(help='command helps')
+
+add_subparser = subparsers.add_parser('add', help='add command help')
+add_subparser.add_argument('task', type=str, help='task message')
+add_subparser.set_defaults(func=add)
+
+get_subparser = subparsers.add_parser('get', help='get command help')
+get_subparser.set_defaults(func=get)
+
+done_subparser = subparsers.add_parser('done', help='done command help')
+done_subparser.set_defaults(func=done)
+
+args = parser.parse_args(sys.argv[1:])
+
+# Commands
+if args.func == add:
+ args.func(args.task)
+else:
+ args.func()
View
10 setup.py
@@ -0,0 +1,10 @@
+from distutils.core import setup
+
+setup(
+ name='OneTask',
+ version='0.1dev',
+ license='MIT License',
+ long_description='Manage your tasks, one task at a time',
+ requires=['pymongo'],
+ scripts=['onetask']
+)
Please sign in to comment.
Something went wrong with that request. Please try again.