Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 87 lines (65 sloc) 2.74 KB
#!/usr/bin/env python
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from getpass import getuser
from os import path
from textwrap import dedent
from whatidid import commands
class Main(object):
''' Main class for whatidid (wid).
A plain text way of remembering what you did
def __init__(self, **kwargs):
self.command = kwargs.get('command', 'notfound');
self.message = kwargs.get('message', None)
self.week = kwargs.get('week', None)
tags = kwargs.get('tags', '')
if tags:
self.tags = tags.split(',')
self.tags = []
if not self.command == 'init':
if not path.exists('%s/.widrc' % (path.expanduser('~'))):
print u'wid is not setup properly, you should run: wid init'
getattr(self, 'command_' + self.command.replace('-','_'))()
def command_init(self):
command = commands.InitCommand()
def command_update(self):
command = commands.UpdateCommand(message=self.message, tags=self.tags)
def command_update_show(self):
command = commands.UpdateShowCommand(week=self.week)
def command_todo(self):
command = commands.TodoCommand(message=self.message, tags=self.tags)
def command_todo_show(self):
command = commands.TodoShowCommand(tags=self.tags)
def command_notfound(self):
print u'The command was not found'
if __name__ == '__main__':
description = dedent('''\
A minimalist command line app for life logging.
wid update\t\tAdd an update to your updates. -m is required, -t is optional
wid update-show\tLists all of your current updates. -w is optional
wid todo\t\tAdd an todo to your todos. -m is required, -t is optional.
wid todo-show\t\tLists all of your todos.
parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter, description=description)
parser.add_argument('command', metavar='COMMAND', type=str,
help=u'A command, ie: update, update-show, update-mail')
parser.add_argument('-m', '--message', type=str, metavar='"A message"', help=u'A message')
parser.add_argument('-t', '--tags', type=str, metavar='tag1[,tag2,tag3]',
help=u'A tag or comma separated list of tags')
parser.add_argument('-w', '--week', type=str, metavar='NN', help=u'A week number to display all events.')
args = parser.parse_args()
main = Main(command=args.command,