]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/xohtml/xohtml.sh
zfs: merge openzfs/zfs@043c6ee3b
[FreeBSD/FreeBSD.git] / usr.bin / xohtml / xohtml.sh
1 #!/bin/sh
2 #!/bin/sh
3 #
4 # Copyright (c) 2014, Juniper Networks, Inc.
5 # All rights reserved.
6 # This SOFTWARE is licensed under the LICENSE provided in the
7 # ../Copyright file. By downloading, installing, copying, or otherwise
8 # using the SOFTWARE, you agree to be bound by the terms of that
9 # LICENSE.
10 # Phil Shafer, July 2014
11 #
12
13 BASE=/usr/share/libxo
14 VERSION=1.6.0
15 CMD=cat
16 DONE=
17 WEB=http://juniper.github.io/libxo/${VERSION}/xohtml
18
19 do_help () {
20     echo "xohtml: wrap libxo-enabled output in HTML"
21     echo "Usage: xohtml [options] [command [arguments]]"
22     echo "Valid options are:"
23     echo "    -b <basepath> | --base <basepath>"
24     echo "    -c <command> | --command <command>"
25     echo "    -f <output-file> | --file <output-file>"
26     exit 1
27 }
28
29 while [ -z "$DONE" -a ! -z "$1" ]; do
30     case "$1" in
31         -b|--base)
32             shift;
33             BASE="$1";
34             shift;
35             ;;
36         -c|--command)
37             shift;
38             CMD="$1";
39             shift;
40             ;;
41         -f|--file)
42             shift;
43             FILE="$1";
44             shift;
45             exec > "$FILE";
46             ;;
47         -w|--web)
48             shift;
49             BASE="${WEB}";
50             ;;
51
52         -*)
53             do_help
54             ;;
55         *)
56             DONE=1;
57             XX=$1;
58             shift;
59             CMD="$XX --libxo=html $@"
60             ;;
61     esac
62 done
63
64 if [ "$CMD" = "cat" -a -t 0 ]; then
65     do_help
66 fi
67
68 echo '<html>'
69 echo '<head>'
70 echo '<meta http-equiv="content-type" content="text/html; charset=utf-8"/>'
71 echo '<link rel="stylesheet" href="'$BASE'/xohtml.css">'
72 echo '<link rel="stylesheet" href="'$BASE'/external/jquery.qtip.css"/>'
73 echo '<script type="text/javascript" src="'$BASE'/external/jquery.js"></script>'
74 echo '<script type="text/javascript" src="'$BASE'/external/jquery.qtip.js"></script>'
75 echo '<script type="text/javascript" src="'$BASE'/xohtml.js"></script>'
76 echo '<script>'
77 echo '</script>'
78 echo '</head>'
79 echo '<body>'
80
81 $CMD
82
83 echo '</body>'
84 echo '</html>'
85
86 exit 0