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