Skip to content

Commit f625b0f

Browse files
committed
Add -v|--verbose option
1 parent 15260eb commit f625b0f

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: test doc release
22

33
BIN := bin/shove
4-
VERSION := $(shell $(BIN) -v)
4+
VERSION := $(shell $(BIN) -V)
55

66
SHELLS := /bin/sh /bin/bash /bin/zsh dash
77
TESTS := t/basic.t t/group.t

bin/shove

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ for opt in "$@"; do
2525
shift 2
2626
fi
2727
;;
28+
"-v" | "--verbose" )
29+
SHOVE_VERBOSE=1
30+
shift
31+
;;
2832
"-h" | "--help" )
2933
help
3034
;;
31-
"-v" | "--version" )
35+
"-V" | "--version" )
3236
echo $version
3337
exit 0
3438
;;
@@ -45,10 +49,16 @@ SHOVE_SHELL=${SHOVE_SHELL:-$SHELL}
4549
SHOVE_TMPFILE=./.shove.tmp.sh
4650

4751
: > $SHOVE_TMPFILE
48-
echo ". ${bin_dir}/../lib/t.shrc" >> $SHOVE_TMPFILE
49-
echo "t_init" >> $SHOVE_TMPFILE
52+
_add() {
53+
echo "$1" >> $SHOVE_TMPFILE
54+
}
55+
_add ". ${bin_dir}/../lib/t.shrc"
56+
_add "t_init"
57+
if [[ ${SHOVE_VERBOSE:-} ]]; then
58+
_add "__t_verbose=1"
59+
fi
5060
cat $target >> $SHOVE_TMPFILE
51-
echo "t_report" >> $SHOVE_TMPFILE
61+
_add "t_report"
5262

5363
if [ ${SHOVE_DEBUG:-} ]; then
5464
SHOVE_SHELL="$SHOVE_SHELL -x"

lib/t.shrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ __t_ok=0
66
__t_ng=0
77
__t_shell=""
88
__t_level=0
9+
__t_verbose=""
910

1011
_t_incr() {
1112
local _var=$1
@@ -68,7 +69,9 @@ t_diag() {
6869
}
6970

7071
t_pass() {
71-
_t_put "ok $__t_idx - ${1:-pass}"
72+
if [ "$__t_verbose" ]; then
73+
_t_put "ok $__t_idx - ${1:-pass}"
74+
fi
7275
_t_either __t_ok
7376
return 0
7477
}

0 commit comments

Comments
 (0)