diff --git a/blog b/blog index 7f6b45f..5fcc409 100755 --- a/blog +++ b/blog @@ -4,6 +4,7 @@ use v6.e.PREVIEW; use DB; use DB::BlogMeta; use DB::MarkdownPost; +use DB::IdrisPost; my %*SUB-MAIN-OPTS = :named-anywhere, @@ -57,7 +58,6 @@ multi MAIN( } #| Create a new markdown post - multi MAIN( "new", "markdown", @@ -82,3 +82,29 @@ multi MAIN( say 'Post inserted with id ', $id; say 'Post has slugs: ', $db.posts{$id}.all-slugs; } + +#| Create a new idris post +multi MAIN( + "new", + "idris", + #| The path to the idris file + IO::Path(Str) $source, + #| The path of the database file + IO::Path(Str) :$db-dir = $default-db-dir, + #| The date/time the post should be recorded as posted at + DateTime(Str) :$posted-at = DateTime.now, + #| Should the post be hidden from the archive? + Bool :$hidden = False, +) { + my $db = read-db $db-dir; + my $id = + $db.insert-post: + IdrisPost.new( + source => $source.absolute.IO, + posted-at => $posted-at, + hidden => $hidden, + ); + $db.write: $db-dir; + say 'Post inserted with id ', $id; + say 'Post has slugs: ', $db.posts{$id}.all-slugs; +}