std.c: Improve some comments
[sunny256-utils.git] / skriv
blob440f61cbc5e13a95529851043ac81e464dac2f4e
1 #!/bin/sh
3 #==============================================================================
4 # skriv
5 # File ID: 2706f4c0-b7bb-11ee-bb6f-83850402c3ce
7 # [Description]
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #==============================================================================
13 progname=skriv
14 VERSION=0.0.0
16 opt_help=0
17 opt_landscape=0
18 opt_pretty=0
19 opt_printer=
20 opt_quiet=0
21 opt_two_sided=0
22 opt_verbose=0
23 while test -n "$1"; do
24 case "$1" in
25 -2|--two-sided) opt_two_sided=1; shift ;;
26 -P|--printer) opt_printer="$2"; shift 2 ;;
27 -h|--help) opt_help=1; shift ;;
28 -l|--landscape) opt_landscape=1; shift ;;
29 -p|--pretty) opt_pretty=1; shift ;;
30 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
31 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
32 --version) echo $progname $VERSION; exit 0 ;;
33 --) shift; break ;;
35 if printf '%s\n' "$1" | grep -q ^-; then
36 echo "$progname: $1: Unknown option" >&2
37 exit 1
38 else
39 break
41 break ;;
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 Usage: $progname [options]
52 Options:
54 -2, --two-sided
55 Print on both pages of the paper.
56 -h, --help
57 Show this help.
58 -l, --landscape
59 Use landscape format.
60 -P DEST, --printer DEST
61 Use DEST as print destination.
62 -p, --pretty
63 Create page headers and use syntax highlighting.
64 -q, --quiet
65 Be more quiet. Can be repeated to increase silence.
66 -v, --verbose
67 Increase level of verbosity. Can be repeated.
68 --version
69 Print version information.
71 END
72 exit 0
75 pretty_str=
76 if [ "$opt_pretty" = "1" ]; then
77 pretty_str="-p"
80 printer_str=
81 if [ -n "$opt_printer" ]; then
82 printer_str="-P $opt_printer"
85 rot_str=
86 if [ "$opt_landscape" = "1" ]; then
87 rot_str="-o orientation-requested=4"
90 sides_str=
91 if [ "$opt_two_sided" = "1" ]; then
92 if [ "$opt_landscape" = "1" ]; then
93 sides_str="-o sides=two-sided-short-edge"
94 else
95 sides_str="-o sides=two-sided-long-edge"
99 lpr \
100 -o fit-to-page \
101 -o print-quality=5 \
102 $pretty_str \
103 $printer_str \
104 $rot_str \
105 $sides_str \
106 "$@"
108 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :