#!/usr/bin/env python import sys from datetime import datetime from stamper import DATE_FORMAT, Stamper def usage(name): msg = """ Usage: To start tracking time: %(name)s To record time for a given task: %(name)s customer action """ % {'name': name} print(msg) if __name__ == '__main__': s = Stamper() s.load_stamps() if len(sys.argv) == 1: # stamp! s.stamp(datetime.today().strftime(DATE_FORMAT), None, None, None) elif len(sys.argv) == 3: # record! last_stamp = s.last_stamp() current_start = last_stamp['end'] if not current_start: current_start = last_stamp['start'] s.stamp(current_start, datetime.today().strftime(DATE_FORMAT), sys.argv[1], sys.argv[2]) else: usage(sys.argv[0]) sys.exit(1) s.save_stamps()