mktar: Use `wc` instead of `du` in summary message
[sunny256-utils.git] / Lib / std / Add_test
blob5076dcd4bda4f83d0af89a9cf32c6a76f3ebf49e
1 #!/usr/bin/env bash
3 #=======================================================================
4 # Add_test
5 # File ID: STDuuidDTS
7 # Create new *.t file in the current directory. Specify a name without
8 # the .t extension and a file with some common option tests will be
9 # created.
11 # Author: Øyvind A. Holm <sunny@sunbase.org>
12 # License: GNU General Public License version 2 or later.
13 #=======================================================================
15 progname=Add_test
16 VERSION=0.3.0
18 ARGS="$(getopt -o "\
22 " -l "\
23 help,\
24 quiet,\
25 verbose,\
26 version,\
27 " -n "$progname" -- "$@")"
28 test "$?" = "0" || exit 1
29 eval set -- "$ARGS"
31 opt_help=0
32 opt_quiet=0
33 opt_verbose=0
34 while :; do
35 case "$1" in
36 -h|--help) opt_help=1; shift ;;
37 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
38 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
39 --version) echo $progname $VERSION; exit 0 ;;
40 --) shift; break ;;
41 *) echo $progname: Internal error >&2; exit 1 ;;
42 esac
43 done
44 opt_verbose=$(($opt_verbose - $opt_quiet))
46 if test "$opt_help" = "1"; then
47 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
48 cat <<END
50 Create new *.t file in the current directory. Specify a name without the
51 .t extension and a file with some common option tests will be created.
53 Usage: $progname [options] testname
55 Options:
57 -h, --help
58 Show this help.
59 -q, --quiet
60 Be more quiet. Can be repeated to increase silence.
61 -v, --verbose
62 Increase level of verbosity. Can be repeated.
63 --version
64 Print version information.
66 END
67 exit 0
70 name=$1
71 if test -z "$name"; then
72 echo $progname: Missing test file name >&2
73 exit 1
75 std perl-tests-tab $name.t -t progname=$name
76 chmod +x $name.t