#! /bin/bash

# Manual page header
echo $'
=============
 twiki-admin
=============

-----------------------------
Administrate TWiki instances
-----------------------------

:Author: Adrian Perez <aperez@igalia.com>
:Manual section: 1

SYNOPSIS
========

``twiki-admin action [arguments...]``

DESCRIPTION
===========

``twiki-admin`` allows to automate management of TWiki instances and their
related Apache configuration file snippets. Its main purpose is to avoid the
need to manually tackle parts of the wiki creation and configuration
process.

USAGE
=====
'

for action in twiki-admin-*
do
	desc=$(sed -e '/^##-/p' -e d "${action}")
	usage=$(sed -e '/^##:/p' -e d "${action}")

	actionname=${action#twiki-admin-}

	echo "\`\`twiki-admin ${actionname}${usage#\#\#:}\`\`"
	while read -r line ; do
		echo "  ${line}"
	done <<< "${desc#\#\#-}"
	echo
	while read -r dummy argname argdesc ; do
		echo "  :${argname}: ${argdesc}"
	done < <( sed -e '/^##+/p' -e d "${action}" )
	echo
done


echo '
RETURN VALUE
============

``twiki-admin`` returns exit status 0 on success.

ENVIRONMENT
===========

The ``TWIKI_ADMIN_CONF`` environment variable may be defined to specify an
alternative configuration other than ``/etc/admintools/twiki-admin.conf``.

Debugging output can be achieved by defining ``TWIKI_ADMIN_DEBUG`` to
a non-zero, integer value. Debug levels are cumulative, in the sense that
a particular level includes features from the lower ones along with its
own debugging features. Currently, debugging levels do the following:

:``TWIKI_ADMIN_DEBUG=0``: No debugging output is ever produced.
:``TWIKI_ADMIN_DEBUG=1``: External commands and actions being taken are
	printed to standard output, prefixed with three stars (``***``). Prints
	out configuration values loaded from the configuration file.
:``TWIKI_ADMIN_DEBUG=2``: Disables execution of commands and actions
	prefixed with three stars (``***``).
:``TWIKI_ADMIN_DEBUG=3``: Enables tracing in the shell with ``set -x``.

FILES
=====

The configuration file must be present at
``/etc/admintools/twiki-admin.conf``.
'


