aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorMark Powers <mark@marks.kitchen>2020-12-26 10:47:44 -0600
committerMark Powers <mark@marks.kitchen>2020-12-26 10:47:44 -0600
commit533943a74dce31f81211b86c49052c341cd5c9eb (patch)
tree9f55374ac9bdaada45cba2c988a3008fc03e413d /main.py
parent0b0ddb7c6f259622d9a153eef11888d0706c9ef5 (diff)
Add today command
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py16
1 files 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 <path> <title> <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: