More blog commands
This commit is contained in:
parent
b55a4f2b41
commit
e05269b9a3
1 changed files with 60 additions and 1 deletions
61
blog
61
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue