From 597455e276ab8f4f45462fb067fd5ed2e9874a3a Mon Sep 17 00:00:00 2001 From: Will Carhart Date: Wed, 6 May 2020 01:58:31 -0700 Subject: [PATCH] Added refresh command --- README.md | 1 + lurker | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4254f39..2cef54a 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Available commands: more - show the next 10 posts (up to 500) less - show the previous 10 posts back - show the previous list of posts again + refresh - refresh the master post list, which will reset the ordering of posts clear - clear the screen exit - quit lurker ``` diff --git a/lurker b/lurker index c62a865..b8c99f8 100755 --- a/lurker +++ b/lurker @@ -25,7 +25,8 @@ function __verifyjq { function __getmasterlist { # get master list of posts (500 total) - __startspin "Initializing" + # $1 is the loading message to use + __startspin "${1:-Initializing}" mkdir -p "${HOME}/.lurker" # shellcheck disable=SC2178 masterpostlist="$(curl -s 'https://hacker-news.firebaseio.com/v0/topstories.json')" @@ -559,6 +560,12 @@ function __lurk { clear) clear ;; + refresh) + __getmasterlist "Refreshing" + startindex=0 + endindex=$(( startindex + 9 )) + __getposts "$startindex" "$endindex" "Fetching posts" + ;; h|help|list) echo "Available commands:" echo " help - show this help menu" @@ -570,6 +577,7 @@ function __lurk { echo " more - show the next 10 posts (up to 500)" echo " less - show the previous 10 posts" echo " back - show the previous list of posts again" + echo " refresh - refresh the master post list, which will reset the ordering of posts" echo " clear - clear the screen" echo " exit - quit lurker" ;;