aboutsummaryrefslogtreecommitdiff
path: root/doc/cli.sh
blob: d022a47faf798bc45373519b33f5b4b5527b1ea4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /usr/bin/env bash

version="0.2.0"
date="XX January 2016"

trap 'exit 1' ERR
set -o errtrace # Trap in functions.

function info () { echo "$*" 1>&2; }
function error () { info "$*"; exit 1; }

while [ $# -gt 0 ]; do
  case $1 in
    --clean)
      rm -f bpkg*.xhtml bpkg*.1
      exit 0
      ;;
    *)
      error "unexpected $1"
      ;;
  esac
done

function compile ()
{
  local n=$1; shift

  # Use a bash array to handle empty arguments.
  #
  local o=()
  while [ $# -gt 0 ]; do
    o=("${o[@]}" "$1")
    shift
  done

  cli -I .. -v version="$version" -v date="$date" --include-base-last "${o[@]}" \
--generate-html --html-prologue-file prologue.xhtml --html-epilogue-file \
epilogue.xhtml --html-suffix .xhtml ../bpkg/$n.cli

  cli -I .. -v version="$version" -v date="$date" --include-base-last "${o[@]}" \
--generate-man --man-prologue-file prologue.1 --man-epilogue-file epilogue.1 \
--man-suffix .1 ../bpkg/$n.cli
}

o="--output-prefix bpkg- --class-doc bpkg::common_options=short"

# A few special cases.
#
compile "common" $o --output-suffix "-options" --class-doc bpkg::common_options=long
compile "bpkg" $o --output-prefix "" --suppress-undocumented --class-doc bpkg::commands=short --class-doc bpkg::topics=short

pages="cfg-add cfg-create cfg-fetch help pkg-build pkg-clean pkg-configure \
pkg-disfigure pkg-drop pkg-fetch pkg-install pkg-purge pkg-status \
pkg-uninstall pkg-unpack pkg-update pkg-verify rep-create rep-info"

for p in $pages; do
  compile $p $o
done