points.py 897 Bytes
Newer Older
1
o#!/usr/bin/env python3
Nico Schottelius's avatar
Nico Schottelius committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

import argparse
import datetime
import sys

mymap={
    'tweet': 2,
    'email': 2,
    'ticket': 3 }

wchoices = [ x for x in mymap ]

parser = argparse.ArgumentParser(description='Scoooooooring')

fname="/home/nico/vcs/notes/points.org"


parser.add_argument('-m', '--method', help="read / write", choices=["r", "w"], default="w")
parser.add_argument('-w', '--what', help="What I did", required=True, choices=wchoices)
parser.add_argument('-a', '--amount', help="How much of it", required=False, default=1)


args = parser.parse_args(sys.argv[1:])

count = int(args.amount)
when  = datetime.date.today().isoformat()
what  = args.what

if args.method == "w":
   with open(fname, "a") as fd:
      for x in range(count):
         to_print="| {} | {} |".format(when, what)
         print(to_print)
         fd.write(to_print)
         fd.write("\n")


else:
   print("ok")