#!/bin/bash # Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # Ghetto script to generate a repoman.1 manpage # based upon `repoman --help` so we dont have to # maintain both files. for repoman in . ./bin ../bin ; do repoman=${repoman}/repoman [[ -x ${repoman} ]] && break done man=repoman.1 cat repoman.1.header > $man state=header $repoman -h | \ while read line ; do set -- ${line} case ${state} in header) if [[ ${line} == *Options* ]] ; then state=options echo ".SH OPTIONS" >> $man fi ;; options) if [[ $1 == -* ]] ; then if [[ $1 == *, ]] ; then shopt="\fB${1/,}\fR, " longopt=$2 shift ; shift else shopt="" longopt=$1 shift fi cat <<-EOF >> $man .TP ${shopt}\fB${longopt}\fR $* EOF elif [[ $1 == *Modes* ]] ; then state=modes echo ".SH MODES" >> $man fi ;; modes) if [[ -n $1 ]] ; then mode=$1 shift cat <<-EOF >> $man .TP .B ${mode} $* EOF else state=keywords echo ".SH QA KEYWORDS" >> $man fi ;; keywords) if [[ $1 == *.* ]] ; then mode=$1 shift cat <<-EOF >> $man .TP .B ${mode} $* EOF fi ;; esac done cat repoman.1.tail >> $man