Upgrade yt-dlp from version stable@2024.10.07 to stable@2024.12.13
[sunny256-utils.git] / Lib / std / book-cmark / bin / loop-stat
blob1b247eee8665e57258f3fd07f0e9a7c0ece62334
1 #!/usr/bin/env bash
3 #=======================================================================
4 # loop-stat
5 # File ID: STDuuidDTS
7 # [Description]
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #=======================================================================
13 progname=loop-stat
14 VERSION=0.2.0
16 ARGS="$(getopt -o "\
21 " -l "\
22 colour,\
23 help,\
24 quiet,\
25 verbose,\
26 version,\
27 " -n "$progname" -- "$@")"
28 test "$?" = "0" || exit 1
29 eval set -- "$ARGS"
31 opt_colour=0
32 opt_help=0
33 opt_quiet=0
34 opt_verbose=0
35 while :; do
36 case "$1" in
37 -c|--colour) opt_colour=1; shift ;;
38 -h|--help) opt_help=1; shift ;;
39 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
40 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
41 --version) echo $progname $VERSION; exit 0 ;;
42 --) shift; break ;;
43 *) echo $progname: Internal error >&2; exit 1 ;;
44 esac
45 done
46 opt_verbose=$(($opt_verbose - $opt_quiet))
48 if test "$opt_help" = "1"; then
49 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
50 cat <<END
52 Usage: $progname [options] FILE [FILES [...]]
54 Options:
56 -c, --colour
57 Use colour in output; red if behind schedule, green if ahead.
58 -h, --help
59 Show this help.
60 -q, --quiet
61 Be more quiet. Can be repeated to increase silence.
62 -v, --verbose
63 Increase level of verbosity. Can be repeated.
64 --version
65 Print version information.
67 END
68 exit 0
71 files="$@"
73 begintime="$(date -u +"%Y-%m-%d %H:%M:%S")"
74 beginvalue=$(bin/stats --data $files | wc -w)
76 colour_str="$(test "$opt_colour" = "1" && echo " --colour")"
78 while :; do
79 outp="$(
80 stats_outp="$(bin/stats$colour_str $files)"
81 echo "$stats_outp"
82 currgoal=$(echo "$stats_outp" | grep ^Goal | awk '{ print $2 }')
83 currtime="$(TZ=UTC stat $files -c %y | head -c 19)"
84 echo
85 goal -c "$currtime" "$begintime" $beginvalue $currgoal $(
86 bin/stats --data $files | wc -w
89 clear
90 echo "$outp"
91 sleep 2
92 done