[work] Add start time argument
This commit is contained in:
parent
95e4562b29
commit
a8c10982fb
1 changed files with 9 additions and 4 deletions
13
bin/work
13
bin/work
|
@ -132,13 +132,17 @@ def work(args):
|
|||
|
||||
def work_start(args):
|
||||
fields = get_today_fields()
|
||||
hour = start_time.strftime("%H:%M")
|
||||
try:
|
||||
hour = datetime.strptime(args.time, "%H:%M")
|
||||
except ValueError:
|
||||
die("Error: {} is not a valid time".format(args.time))
|
||||
if fields:
|
||||
die("You already started working")
|
||||
with open(TODAY_FILE, "a") as f:
|
||||
f.write("{},{}".format(
|
||||
start_time.strftime("%Y-%m-%d"), hour))
|
||||
log("Started working at {}".format(hour))
|
||||
start_time.strftime("%Y-%m-%d"),
|
||||
hour.strftime("%H:%M")))
|
||||
log("Started working at {}".format(hour.strftime("%H:%M")))
|
||||
|
||||
|
||||
def work_pause(args):
|
||||
|
@ -249,9 +253,10 @@ if __name__ == "__main__":
|
|||
parse_parser = commands.add_parser("parse")
|
||||
|
||||
start_parser.set_defaults(func=work_start)
|
||||
start_parser.add_argument("time", nargs="?", default=datetime.now().strftime("%H:%M"))
|
||||
pause_parser.set_defaults(func=work_pause)
|
||||
end_parser.add_argument("description")
|
||||
end_parser.set_defaults(func=work_end)
|
||||
end_parser.add_argument("description")
|
||||
export_parser.set_defaults(func=work_export)
|
||||
parse_parser.set_defaults(func=work_parse)
|
||||
parse_parser.add_argument("file")
|
||||
|
|
Loading…
Reference in a new issue