From e05269b9a30a43957c4cb45cb878ef28b8df53dd Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Sat, 8 Feb 2025 23:38:27 -0500 Subject: [PATCH] More blog commands --- blog | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/blog b/blog index 159ab7f..9918182 100755 --- a/blog +++ b/blog @@ -72,6 +72,7 @@ multi MAIN( #| Create a new markdown post multi MAIN( + "post", "new", "markdown", #| The path to the markdown file @@ -98,6 +99,7 @@ multi MAIN( #| Create a new idris post multi MAIN( + "post", "new", "idris", #| The path to the idris file @@ -127,7 +129,8 @@ multi MAIN( #| Update the last editied time on a post multi MAIN( - "touch", + "post", + "edit", #| The post id to touch Int:D $id, #| The path of the database file @@ -195,3 +198,59 @@ multi MAIN( } say $table; } + +#| Display information about a post +multi MAIN( + "post", + "info", + #| The id of the post to display information for + Int $id, + #| The path of the database directory + IO::Path(Str) :$db-dir = $default-db-dir, + #| Display all of the information and not just the primaries + Bool :$full, +) { + my $db = read-db $db-dir; + my $post = $db.posts{$id.Int}; + given $post { + say 'Title: ', .title; + say 'Type: ', .WHAT.^name; + say 'Source: ', .source.relative; + if .hidden { + say "Hidden"; + } + if .all-slugs { + if $full { + say 'Slugs: '; + for .all-slugs -> $slug { + say ' * ', $slug; + } + } else { + say 'Primary Slug: ', .all-slugs[*-1]; + } + } else { + say 'Slugs: []'; + } + if .tags { + say 'Tags:'; + for .tags -> $tag { + say ' * ', $tag; + } + } + given .posted-at { + say 'Posted At: ', .Date.Str, ' ', .hh-mm-ss; + } + if .edited-at { + if $full { + say 'Edits: '; + for .edited-at.sort.reverse { + say ' * ', .Date.Str, ' ', .hh-mm-ss; + } + } else { + given .edited-at.sort[*-1] { + say 'Last Edited At: ', .Date.Str, ' ', .hh-mm-ss; + } + } + } + } +}