add new idris
This commit is contained in:
parent
3b0e34e66e
commit
d9749311cb
1 changed files with 27 additions and 1 deletions
28
blog
28
blog
|
@ -4,6 +4,7 @@ use v6.e.PREVIEW;
|
||||||
use DB;
|
use DB;
|
||||||
use DB::BlogMeta;
|
use DB::BlogMeta;
|
||||||
use DB::MarkdownPost;
|
use DB::MarkdownPost;
|
||||||
|
use DB::IdrisPost;
|
||||||
|
|
||||||
my %*SUB-MAIN-OPTS =
|
my %*SUB-MAIN-OPTS =
|
||||||
:named-anywhere,
|
:named-anywhere,
|
||||||
|
@ -57,7 +58,6 @@ multi MAIN(
|
||||||
}
|
}
|
||||||
|
|
||||||
#| Create a new markdown post
|
#| Create a new markdown post
|
||||||
|
|
||||||
multi MAIN(
|
multi MAIN(
|
||||||
"new",
|
"new",
|
||||||
"markdown",
|
"markdown",
|
||||||
|
@ -82,3 +82,29 @@ multi MAIN(
|
||||||
say 'Post inserted with id ', $id;
|
say 'Post inserted with id ', $id;
|
||||||
say 'Post has slugs: ', $db.posts{$id}.all-slugs;
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue