Commit a66e9c74 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: adjust completion parser

- restrict to text between "^[Oo]ptions:" and "-help-full" to avoid
  potential issues when more text is introduced in the usage output.
parent d29388f1
......@@ -147,7 +147,8 @@ HEADER
# -hostRoots Advanced distributed run option
# -roots Advanced distributed run option
#
# Terminate parsing on first appearance of -help-full.
# Begin parsing after first appearance of "^[Oo]ptions:"
# 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.
......@@ -155,7 +156,8 @@ extractOptions()
{
local appName="$1"
local helpText=$($appName -help-full 2>/dev/null | \
sed -ne 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \
sed -ne '1,/^[Oo]ptions:/d' \
-e 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \
-e '/^-hostRoots /d; /^-roots /d;' \
-e 'y/,/ /; s/=.*$/=/;' \
-e '/^-[^ ]* </{ s/^\(-[^ ]* <\).*$/\1/; p; d }' \
......
......@@ -139,14 +139,16 @@ _of_complete_()
# -opt2 <arg> descrip
# -help-full
# Ignore -help-man (internal option).
# Terminate parsing on first appearance of -help-full
# Begin parsing after first appearance of "^[Oo]ptions:"
# 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.
if [ -z "$choices" ]
then
local helpText=$($appName -help-full 2>/dev/null | \
sed -ne 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \
sed -ne '1,/^[Oo]ptions:/d' \
-e 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \
-e 'y/,/ /; s/=.*$/=/;' \
-e '/^-[^ ]* </{ s/^\(-[^ ]* <\).*$/\1/; p; d }' \
-e 's/^\(-[^ ]*\).*$/\1/; p; /^-help-full/q;' \
......
......@@ -318,8 +318,9 @@ void Foam::argList::printUsage(bool full) const
Info<< ']';
}
}
Info<< nl;
Info<< "\noptions:\n";
Info<< "Options:\n";
for (const word& optName : validOptions.sortedToc())
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment