#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG					#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright 2007 - 2017 Christopher Bratusek		#
#							#
#########################################################

if ! which ps2pdf; then
	echo -e "ps2pdf not found, man2pdf won't work."
	exit 1
fi

case ${1} in

	--help | -h | "")
		bashstyle-help -a "Christopher Roy Bratusek" -e "nano@jpberlin.de" -h "http://www.nanolx.org/"\
			-l "GNU GPL v3" -n "man2pdf" -s "create PDF from a manpage" -v "${BSNG_VERSION}" -y "${BSNG_YEAR}"\
			-o "manpage:bash|manpage to create a PDF from"
	;;

	* )
		man -t "${1}" | ps2pdf - >"${1}.pdf" || echo "manpage ${1} does not exist"
	;;

esac
