Skip to content

Commit

Permalink
A pottery show command to read recent shards
Browse files Browse the repository at this point in the history
  • Loading branch information
npryce committed Aug 20, 2018
1 parent 5b74aba commit fefab1e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/pottery-show
@@ -0,0 +1,31 @@
#!/bin/bash
set -e
eval "$($(dirname $0)/pottery-config)"

## usage: pottery show [COUNT]
##
## Displays the COUNT most recent entries recorded in the history.
##
## If COUNT is not given, it defaults to 10.
##
## E.g. to show the 10 most recent entries
##
## pottery show
##
## E.g. to show the 5 most recent entries
##
## pottery show 5
##

count=${1:-10}
rootdir=$("$pottery_bin_dir/_pottery_dir")

for f in $(find $rootdir -type f -name '*.md' | sort --reverse --dictionary-order | head -n $count)
do
f_name=$(basename $f)
f_date=${f_name:0:20}
echo $f_date
echo
cat $f
echo
done
20 changes: 20 additions & 0 deletions tests/shows-shards-newest-first.expected
@@ -0,0 +1,20 @@
pottery init
TEST_TIME=1992-01-12T16:34:23Z pottery post "First post"
docs/project-history/1992/1992-01/1992-01-12T16:34:23Z_post_FAKEUNIQUEID.md
TEST_TIME=1992-01-12T17:00:00Z pottery post "Second post."
docs/project-history/1992/1992-01/1992-01-12T17:00:00Z_post_FAKEUNIQUEID.md
TEST_TIME=1992-01-13T16:34:23Z pottery post "It's a new day."
docs/project-history/1992/1992-01/1992-01-13T16:34:23Z_post_FAKEUNIQUEID.md
pottery show
1992-01-13T16:34:23Z

It's a new day.

1992-01-12T17:00:00Z

Second post.

1992-01-12T16:34:23Z

First post

5 changes: 5 additions & 0 deletions tests/shows-shards-newest-first.sh
@@ -0,0 +1,5 @@
pottery init
TEST_TIME=1992-01-12T16:34:23Z pottery post "First post"
TEST_TIME=1992-01-12T17:00:00Z pottery post "Second post."
TEST_TIME=1992-01-13T16:34:23Z pottery post "It's a new day."
pottery show

0 comments on commit fefab1e

Please sign in to comment.