Skip to content

Commit 3f473ed

Browse files
committed
--help
1 parent 41fc7ab commit 3f473ed

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* 2023-02-03, Version 1.8.0
2+
* Option to show the last log entries
13
* 2022-08-31, Version 1.7.0
24
* Available space in %
35
* 2022-08-17, Version 1.6.0

RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Available space in %
1+
Option to show the last log entries

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.7.0
1+
1.8.0

tmstatus.sh

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313

1414
# shellcheck disable=SC2034
15-
VERSION=1.7.0
15+
VERSION=1.8.0
1616

1717
export LC_ALL=C
1818

@@ -83,14 +83,44 @@ format_timespan() {
8383

8484
}
8585

86+
usage() {
87+
88+
echo
89+
echo "Usage: tmstatus.sh [OPTIONS]"
90+
echo
91+
echo "Options:"
92+
# Delimiter at 78 chars ############################################################
93+
echo " -h,--help,-? This help message"
94+
echo " -l,--log [lines] Show the last log lines"
95+
echo
96+
echo "Report bugs to https://github.com/matteocorti/tmstatus.sh/issues"
97+
echo
98+
99+
exit
100+
101+
}
102+
86103
COMMAND_LINE_ARGUMENTS=$*
87104

88105
while true; do
89106

90107
case "$1" in
91-
-l | --log)
92-
SHOWLOG=1
93-
shift
108+
-h | --help)
109+
usage
110+
;;
111+
-l | --log)
112+
SHOWLOG=20
113+
if [ $# -gt 1 ]; then
114+
# shellcheck disable=SC2295
115+
if [ "${2%${2#?}}"x = '-x' ]; then
116+
shift
117+
else
118+
SHOWLOG=$2
119+
shift 2
120+
fi
121+
else
122+
shift
123+
fi
94124
;;
95125
*)
96126
if [ -n "$1" ]; then
@@ -380,7 +410,7 @@ if [ -n "${SHOWLOG}" ]; then
380410
-e 's/\[//' |
381411
expand -t 27 |
382412
cut -c -"${WIDTH}" |
383-
tail -n 20
413+
tail -n "${SHOWLOG}"
384414

385415
printf '%.s-' $( seq 1 "$(tput cols)" )
386416
echo

0 commit comments

Comments
 (0)