From 533943a74dce31f81211b86c49052c341cd5c9eb Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Sat, 26 Dec 2020 10:47:44 -0600 Subject: Add today command --- main.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index a81c8b5..168c7bf 100755 --- a/main.py +++ b/main.py @@ -5,13 +5,23 @@ import subprocess from config import config import graphql_queries import re +import datetime def print_item(item): trimmmed_path = item["path"][:17]+"..." if len(item["path"]) > 20 else item["path"] print("| %6s | %20s | %44s |" % (item["id"], trimmmed_path, item["title"]) ) +def today(argv): + if len(argv) != 0: + print("Usage: ./main.py today") + today = datetime.datetime.now() + path = today.strftime("%Y/%b/%d").lower() + date_int = int(today.strftime("%d")) + title = today.strftime("%B ") + str(date_int) + create([path, title]) + def create(argv): - if len(argv) != 2 or len(argv) != 3: + if len(argv) < 2 or len(argv) > 3: print("Usage: ./main.py create <content?>") sys.exit(1) path = argv[0] @@ -115,12 +125,14 @@ def main(): print("\ttree <contains?>") print("\tsingle <id|path>") print("\tedit <id|path>") + print("\ttoday") sys.exit(0) commands = { "create": create, "tree": tree, "single": single, - "edit": edit + "edit": edit, + "today": today } command = sys.argv[1] if command in commands: -- cgit v1.2.3