SMOLNET PORTAL home about changes
README: add progress indicator script - sfeed - RSS and Atom parser
(URL) git clone git://git.codemadness.org/sfeed (git://git.codemadness.org)
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit e1676198f01a1ba713e1bc9705db8df80cc47cfa
(DIR) parent d871d884d37a2d9e41278198ac52b50850aff969
(URL) Author: Hiltjo Posthuma <hiltjo@codemadness.org> (mailto://) application/vnd.lotus-organizer
Date: Sat, 14 May 2022 12:28:58 +0200
README: add progress indicator script
Diffstat:
M README | 47 +++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/README b/README
@@ -971,6 +971,53 @@ TSV format.
- - -
+Progress indicator
+------------------
+
+The below sfeed_update wrapper script counts the amount of feeds in a sfeedrc
+config. It then calls sfeed_update and pipes the output lines to a function
+that counts the current progress. It writes the total progress to stderr.
+Alternative: pv -l -s totallines
+
+ #!/bin/sh
+ # Progress indicator script.
+
+ # Pass lines as input to stdin and write progress status to stderr.
+ # progress(totallines)
+ progress() {
+ total="$(($1 + 0))" # must be a number, no divide by zero.
+ test "${total}" -le 0 -o "$1" != "${total}" && return
+ LC_ALL=C awk -v "total=${total}" '
+ {
+ counter++;
+ percent = (counter * 100) / total;
+ printf("\033[K") > "/dev/stderr"; # clear EOL
+ print $0;
+ printf("[%s/%s] %.0f%%\r", counter, total, percent) > "/dev/stderr";
+ fflush(); # flush all buffers per line.
+ }
+ END {
+ printf("\033[K") > "/dev/stderr";
+ }'
+ }
+
+ # Counts the feeds from the sfeedrc config.
+ countfeeds() {
+ count=0
+ . "$1"
+ feed() {
+ count=$((count + 1))
+ }
+ feeds
+ echo "${count}"
+ }
+
+ config="${1:-$HOME/.sfeed/sfeedrc}"
+ total=$(countfeeds "${config}")
+ sfeed_update "${config}" | progress "${total}"
+
+- - -
+
Counting unread and total items
-------------------------------
Response: application/gopher-menu
Original URLgopher://codemadness.org/1/git/sfeed/commit/e1676198f01a1...
Content-Typeapplication/gopher-menu; charset=utf-8