Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 02e581bb92
Fetching contributors…

Cannot retrieve contributors at this time

executable file 70 lines (54 sloc) 2.291 kb
#!/usr/bin/env python
from argparse import ArgumentParser
from getpass import getuser
from os import path
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(',')
else:
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'
exit(1)
getattr(self, 'command_' + self.command.replace('-','_'))()
def command_init(self):
command = commands.InitCommand()
command.run()
def command_update(self):
command = commands.UpdateCommand(message=self.message, tags=self.tags)
command.run()
def command_update_show(self):
command = commands.UpdateShowCommand(week=self.week)
command.run()
def command_todo(self):
command = commands.TodoCommand(message=self.message, tags=self.tags)
command.run()
def command_todo_show(self):
command = commands.TodoShowCommand(tags=self.tags)
command.run()
def command_notfound(self):
print u'The command was not found'
exit(1);
if __name__ == '__main__':
parser = ArgumentParser(description=u'Keeping track of what you did this week')
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,
message=args.message,
tags=args.tags,
week=args.week)
Jump to Line
Something went wrong with that request. Please try again.