xref: /freebsd/usr.bin/xohtml/xohtml.sh (revision 47606b869eb149ebb7135d6594c3b9b9f05b9aed)
1#!/bin/sh
2# $FreeBSD$
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
14CMD=cat
15DONE=
16
17do_help () {
18    echo "xohtml: wrap libxo-enabled output in HTML"
19    echo "Usage: xohtml [options] [command [arguments]]"
20    echo "Valid options are:"
21    echo "    -b <basepath> | --base <basepath>"
22    echo "    -c <command> | --command <command>"
23    echo "    -f <output-file> | --file <output-file>"
24    exit 1
25}
26
27while [ -z "$DONE" -a ! -z "$1" ]; do
28    case "$1" in
29        -b|--base)
30            shift;
31            BASE="$1";
32	    shift;
33            ;;
34        -c|--command)
35            shift;
36            CMD="$1";
37	    shift;
38            ;;
39        -f|--file)
40            shift;
41            FILE="$1";
42	    shift;
43	    exec > "$FILE";
44            ;;
45	-*)
46	    do_help
47	    ;;
48	*)
49	    DONE=1;
50	    XX=$1;
51	    shift;
52	    CMD="$XX --libxo=html $@"
53	    ;;
54    esac
55done
56
57if [ "$CMD" = "cat" -a -t 0 ]; then
58    do_help
59fi
60
61echo '<html>'
62echo '<head>'
63echo '<meta http-equiv="content-type" content="text/html; charset=utf-8"/>'
64echo '<link rel="stylesheet" href="'$BASE'/xohtml.css">'
65echo '<link rel="stylesheet" href="'$BASE'/external/jquery.qtip.css"/>'
66echo '<script type="text/javascript" src="'$BASE'/external/jquery.js"></script>'
67echo '<script type="text/javascript" src="'$BASE'/external/jquery.qtip.js"></script>'
68echo '<script type="text/javascript" src="'$BASE'/xohtml.js"></script>'
69echo '<script>'
70echo '</script>'
71echo '</head>'
72echo '<body>'
73
74$CMD
75
76echo '</body>'
77echo '</html>'
78
79exit 0
80