aboutsummaryrefslogtreecommitdiff
path: root/scripts/bloglist.py
diff options
context:
space:
mode:
authorCullum Smith <cullum@sacredheartsc.com>2024-07-03 12:25:01 -0400
committerCullum Smith <cullum@sacredheartsc.com>2024-07-03 12:25:01 -0400
commit56a863f9f11340a9310907e4131b9dc7483df623 (patch)
treec2ea33489c2150bafd74f04e5c9af483f7c2fbf9 /scripts/bloglist.py
downloadwebsite-56a863f9f11340a9310907e4131b9dc7483df623.tar.gz
initial commit
Diffstat (limited to 'scripts/bloglist.py')
-rwxr-xr-xscripts/bloglist.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/bloglist.py b/scripts/bloglist.py
new file mode 100755
index 0000000..9e10354
--- /dev/null
+++ b/scripts/bloglist.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+
+import argparse
+from common import get_blog_posts
+
+DATE_FORMAT = '%Y-%m-%d'
+
+parser = argparse.ArgumentParser('bloglist')
+parser.add_argument('BLOG_DIR', type=str, help='Directory containing markdown blog posts')
+parser.add_argument('LIMIT', nargs='?', default=None, type=int, help='Maximum number of posts to show')
+args = parser.parse_args()
+
+posts = get_blog_posts(args.BLOG_DIR)
+
+if args.LIMIT is not None:
+ posts = posts[0:args.LIMIT]
+
+if len(posts) == 0:
+ print('Nothing has been posted yet!')
+else:
+ for post in posts:
+ post_date = post['date'].strftime(DATE_FORMAT)
+
+ print(f'- [{post["title"]}]({post["href"]}) ({post_date})\n')
+ if post['description']:
+ print(f' {post["description"]}\n')