mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user