#!/bin/sh # # A POSIX shell help2man implementation. Supports most options but does not # output identical manuals. Written in a few hours this is still in "alpha" # status. Please let me know if there are any issues. # # Copyright (c) 2019-2021 Dylan Araps # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. args() { while _arg=$1; do case $1 in -[a-zA-Z]) shift; esac case $_arg in -n|--name=*) _arg_name=${1##--name=} : "${_arg_name:?"$_arg requires an argument"}" ;; -s|--section=*) _arg_section=${1##--section=} : "${_arg_section:?"$_arg requires an argument"}" ;; -m|--manual=*) _arg_manual=${1##--manual=} : "${_arg_manual:?"$_arg requires an argument"}" ;; -S|--source=*) _arg_source=${1##--source=} : "${_arg_source:?"$_arg requires an argument"}" ;; -i|--include=*|-I|--opt-include=*) _arg_include=${1##--include=} : "${_arg_include:?"$_arg requires an argument"}" ;; -o|--output=*) _arg_output=${1##--output=} : "${_arg_output:?"$_arg requires an argument"}" ;; --version) cat <. EOF exit 0 ;; *) exe=$1 break ;; esac shift done } fnr() { # Replace all occurrences of substrings with substrings. This # function takes pairs of arguments iterating two at a time # until everything has been replaced. _fnr=$1 shift 1 while :; do case $_fnr-$# in *"$1"*) _fnr=${_fnr%"$1"*}${2}${_fnr##*"$1"} ;; *-2) break ;; *) shift 2 esac done } clean() { _trim=${1#${1%%[![:space:]]*}} _trim=${_trim%${_trim##*[![:space:]]}} fnr "$_trim" " " " " " " " " } get_help() { case $cmd_stderr in 1) cmd_help=$("$exe" "${_arg_help_option:---help}" 2>&1) ;; *) cmd_help=$("$exe" "${_arg_help_option:---help}") esac || : cmd_help=${cmd_help:?cannot get --help info from "$exe"} } get_version() { case $cmd_stderr in 1) cmd_version_raw=${_arg_version_string:-\ $("$exe" "${_arg_version_option:---version}" 2>&1)} ;; *) cmd_version_raw=${_arg_version_string:-\ $("$exe" "${_arg_version_option:---version}")} esac || : read -r cmd_name cmd_version _junk < "${_arg_output:-/dev/stdout}" .\\" DO NOT MODIFY THIS FILE! It was generated by ${0##*/} 1.48.3. .TH $cmd_NAME "${_arg_section:-1}" "$cmd_date"\ "${_arg_source:-$cmd_version_raw}" "${_arg_manual:-User Commands}" ${HELP_NAME:+"$nl$HELP_NAME"}\ ${HELP_SYNOPSIS:+"$nl$HELP_SYNOPSIS"}\ ${HELP_DESCRIPTION:+"$nl$HELP_DESCRIPTION"}\ ${HELP_OPTIONS:+"$nl$HELP_OPTIONS"}\ ${HELP_REPORTING_BUGS:+"$nl$HELP_REPORTING_BUGS"}\ ${HELP_SEE_ALSO:+"$nl$HELP_SEE_ALSO"} EOF } main "$@"