ENH: improve output formatting for usage information

- generalize output text wrapping, use for usage notes

- add -help-man option for generating manpage content for any OpenFOAM
  application or solver.

  bin/tools/foamCreateManpage as helper
This commit is contained in:
Mark Olesen
2018-11-21 19:55:28 +01:00
parent 6dcc46b187
commit 5187aa13aa
9 changed files with 565 additions and 94 deletions

View File

@ -140,7 +140,8 @@ HEADER
# -opt1 descrip
# -opt2 <arg> descrip
# -help-full
# Terminate parsing on first appearance of -help-full
# Ignore -help-man (internal option).
# Terminate parsing on first appearance of -help-full.
# - options with '=' (eg, -mode=ugo) are not handled very well at all.
# - alternatives (eg, -a, -all) are not handled nicely either,
# for these treat ',' like a space to catch the worst of them.
@ -148,12 +149,15 @@ extractOptions()
{
local appName="$1"
local helpText=$($appName -help-full 2>/dev/null | \
sed -ne 's/^ *//; /^$/d; /^[^-]/d; /^--/d;' \
sed -ne 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \
-e 'y/,/ /; s/=.*$/=/;' \
-e '/^-[^ ]* </{ s/^\(-[^ ]* <\).*$/\1/; p; d }' \
-e 's/^\(-[^ ]*\).*$/\1/; p; /^-help-full/q;' \
)
# After this bit of sed, we have "-opt1" or "-opt2 <"
# for entries without or with arguments.
[ -n "$helpText" ] || {
echo "Error calling $appName" 1>&2
return 1
@ -163,8 +167,8 @@ extractOptions()
local argOpts=($(awk '/</ {print $1}' <<< "$helpText"))
# Array of options without args, but skip the following:
# -help-compat -help-full
local boolOpts=($(awk '!/</ && !/help-(compat|full)/ {print $1}' <<< "$helpText"))
# -help-compat -help-full etc
local boolOpts=($(awk '!/</ && !/help-/ {print $1}' <<< "$helpText"))
appName="${appName##*/}"
echo "$appName" 1>&2