xref: /freebsd/usr.bin/xohtml/xohtml.sh (revision 734e82fe33aa764367791a7d603b383996c6b40b)
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
13BASE=/usr/share/libxo
14VERSION=1.6.0
15CMD=cat
16DONE=
17WEB=http://juniper.github.io/libxo/${VERSION}/xohtml
18
19do_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
29while [ -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
62done
63
64if [ "$CMD" = "cat" -a -t 0 ]; then
65    do_help
66fi
67
68echo '<html>'
69echo '<head>'
70echo '<meta http-equiv="content-type" content="text/html; charset=utf-8"/>'
71echo '<link rel="stylesheet" href="'$BASE'/xohtml.css">'
72echo '<link rel="stylesheet" href="'$BASE'/external/jquery.qtip.css"/>'
73echo '<script type="text/javascript" src="'$BASE'/external/jquery.js"></script>'
74echo '<script type="text/javascript" src="'$BASE'/external/jquery.qtip.js"></script>'
75echo '<script type="text/javascript" src="'$BASE'/xohtml.js"></script>'
76echo '<script>'
77echo '</script>'
78echo '</head>'
79echo '<body>'
80
81$CMD
82
83echo '</body>'
84echo '</html>'
85
86exit 0
87