sj: Add -W/--wait option
[sunny256-utils.git] / jday
blob1b7d9c5ab2c3090b97f4e12bba208e3e7df0d973
1 #!/bin/sh
3 #==============================================================================
4 # jday
5 # File ID: 60e80cc2-a9d9-11e5-986a-fefdb24f8e10
7 # Display current time or another date as Julian Day
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #==============================================================================
13 progname=jday
14 VERSION=0.2.0
16 opt_help=0
17 opt_quiet=0
18 opt_verbose=0
19 while test -n "$1"; do
20 case "$1" in
21 -h|--help) opt_help=1; shift ;;
22 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
23 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
24 --version) echo $progname $VERSION; exit 0 ;;
25 --) shift; break ;;
27 if printf '%s\n' "$1" | grep -q ^-; then
28 echo "$progname: $1: Unknown option" >&2
29 exit 1
30 else
31 break
33 break ;;
34 esac
35 done
36 opt_verbose=$(($opt_verbose - $opt_quiet))
38 if test "$opt_help" = "1"; then
39 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
40 cat <<END
42 Without command line arguments, display current time as Julian Day.
43 Command line arguments are parsed as a ISO date to be displayed as
44 Julian Day.
46 Usage: $progname [options] [DATE]
48 Options:
50 -h, --help
51 Show this help.
52 -q, --quiet
53 Be more quiet. Can be repeated to increase silence.
54 -v, --verbose
55 Increase level of verbosity. Can be repeated.
56 --version
57 Print version information.
59 END
60 exit 0
63 test -z "$1" && julianday=now || julianday="$*"
64 echo "SELECT julianday('$julianday');" | sqlite3
66 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :