aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/bloglist.py
diff options
context:
space:
mode:
authorStonewall Jackson <stonewall@sacredheartsc.com>2023-01-22 09:56:17 -0500
committerStonewall Jackson <stonewall@sacredheartsc.com>2023-01-22 09:56:17 -0500
commit9f1b37fa346a7dcf77c1b6963a6d2e4b871fe5ed (patch)
tree14aa09de866a3283e1b07a94ea9cc6d70fc3e49d /scripts/bloglist.py
downloadwww-9f1b37fa346a7dcf77c1b6963a6d2e4b871fe5ed.tar.gz
www-9f1b37fa346a7dcf77c1b6963a6d2e4b871fe5ed.zip
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')