mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: allow command-line options to be tagged as "advanced"
- advanced options are not displayed with -help, but only with -help-full, which helps retain a better overview of the standard options. Replaces previous ad hoc suppression of -listSwitches, -listRegisteredSwitches etc.
This commit is contained in:
@ -52,6 +52,7 @@ License
|
||||
bool Foam::argList::argsMandatory_ = true;
|
||||
bool Foam::argList::checkProcessorDirectories_ = true;
|
||||
Foam::SLList<Foam::string> Foam::argList::validArgs;
|
||||
Foam::HashSet<Foam::string> Foam::argList::advancedOptions;
|
||||
Foam::HashTable<Foam::string> Foam::argList::validOptions;
|
||||
Foam::HashTable<Foam::string> Foam::argList::validParOptions;
|
||||
Foam::HashTable<Foam::string> Foam::argList::optionUsage;
|
||||
@ -234,10 +235,11 @@ void Foam::argList::addArgument(const string& argName)
|
||||
void Foam::argList::addBoolOption
|
||||
(
|
||||
const word& optName,
|
||||
const string& usage
|
||||
const string& usage,
|
||||
const bool advanced
|
||||
)
|
||||
{
|
||||
addOption(optName, "", usage);
|
||||
addOption(optName, "", usage, advanced);
|
||||
}
|
||||
|
||||
|
||||
@ -245,7 +247,8 @@ void Foam::argList::addOption
|
||||
(
|
||||
const word& optName,
|
||||
const string& param,
|
||||
const string& usage
|
||||
const string& usage,
|
||||
const bool advanced
|
||||
)
|
||||
{
|
||||
validOptions.set(optName, param);
|
||||
@ -253,6 +256,10 @@ void Foam::argList::addOption
|
||||
{
|
||||
optionUsage.set(optName, usage);
|
||||
}
|
||||
if (advanced)
|
||||
{
|
||||
advancedOptions.set(optName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -314,6 +321,7 @@ void Foam::argList::removeOption(const word& optName)
|
||||
{
|
||||
validOptions.erase(optName);
|
||||
optionUsage.erase(optName);
|
||||
advancedOptions.erase(optName);
|
||||
}
|
||||
|
||||
|
||||
@ -361,7 +369,8 @@ void Foam::argList::noLibs()
|
||||
addBoolOption
|
||||
(
|
||||
"no-libs",
|
||||
"disable use of the controlDict libs entry"
|
||||
"disable use of the controlDict libs entry",
|
||||
true // advanced
|
||||
);
|
||||
}
|
||||
|
||||
@ -427,7 +436,7 @@ void Foam::argList::printOptionUsage
|
||||
else if (isspace(str[curr+1]))
|
||||
{
|
||||
// The next one is a space - so we are okay
|
||||
curr++; // otherwise the length is wrong
|
||||
++curr; // otherwise the length is wrong
|
||||
next = str.find_first_not_of(" \t\n", curr);
|
||||
}
|
||||
else
|
||||
@ -1575,16 +1584,8 @@ void Foam::argList::printUsage(bool full) const
|
||||
|
||||
for (const word& optName : validOptions.sortedToc())
|
||||
{
|
||||
// Ad hoc suppression of some options for regular (non-full) help
|
||||
if
|
||||
(
|
||||
!full
|
||||
&&
|
||||
(
|
||||
// '-listXXX' and '-list-XXX' but not '-list'
|
||||
(optName.size() > 4 && optName.startsWith("list"))
|
||||
)
|
||||
)
|
||||
// Suppress advanced options for regular -help.
|
||||
if (advancedOptions.found(optName) && !full)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -97,6 +97,7 @@ SourceFiles
|
||||
#include "stringList.H"
|
||||
#include "SubList.H"
|
||||
#include "SLList.H"
|
||||
#include "HashSet.H"
|
||||
#include "HashTable.H"
|
||||
#include "word.H"
|
||||
#include "fileName.H"
|
||||
@ -193,6 +194,9 @@ public:
|
||||
//- A list of valid (mandatory) arguments
|
||||
static SLList<string> validArgs;
|
||||
|
||||
//- The "advanced" options are shown with -help-full (not with --help)
|
||||
static HashSet<string> advancedOptions;
|
||||
|
||||
//- A list of valid options
|
||||
static HashTable<string> validOptions;
|
||||
|
||||
@ -386,7 +390,8 @@ public:
|
||||
static void addBoolOption
|
||||
(
|
||||
const word& optName,
|
||||
const string& usage = ""
|
||||
const string& usage = "",
|
||||
const bool advanced = false
|
||||
);
|
||||
|
||||
//- Add an option to validOptions with usage information
|
||||
@ -395,7 +400,8 @@ public:
|
||||
(
|
||||
const word& optName,
|
||||
const string& param = "",
|
||||
const string& usage = ""
|
||||
const string& usage = "",
|
||||
const bool advanced = false
|
||||
);
|
||||
|
||||
//- Specify an alias for the option name.
|
||||
|
||||
@ -1,29 +1,34 @@
|
||||
argList::addBoolOption
|
||||
(
|
||||
"listSwitches",
|
||||
"List switches declared in libraries but not set in etc/controlDict"
|
||||
"List switches declared in libraries but not set in etc/controlDict",
|
||||
true // advanced
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"listRegisteredSwitches",
|
||||
"List switches registered for run-time modification"
|
||||
"List switches registered for run-time modification",
|
||||
true // advanced
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"listUnsetSwitches",
|
||||
"List switches declared in libraries but not set in etc/controlDict"
|
||||
"List switches declared in libraries but not set in etc/controlDict",
|
||||
true // advanced
|
||||
);
|
||||
|
||||
#ifdef fvPatchField_H
|
||||
argList::addBoolOption
|
||||
(
|
||||
"listScalarBCs",
|
||||
"List scalar field boundary conditions (fvPatchField<scalar>)"
|
||||
"List scalar field boundary conditions (fvPatchField<scalar>)",
|
||||
true // advanced
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"listVectorBCs",
|
||||
"List vector field boundary conditions (fvPatchField<vector>)"
|
||||
"List vector field boundary conditions (fvPatchField<vector>)",
|
||||
true // advanced
|
||||
);
|
||||
#endif
|
||||
|
||||
@ -31,7 +36,8 @@ argList::addBoolOption
|
||||
argList::addBoolOption
|
||||
(
|
||||
"listFunctionObjects",
|
||||
"List functionObjects"
|
||||
"List functionObjects",
|
||||
true // advanced
|
||||
);
|
||||
#endif
|
||||
|
||||
@ -39,7 +45,8 @@ argList::addBoolOption
|
||||
argList::addBoolOption
|
||||
(
|
||||
"listFvOptions",
|
||||
"List fvOptions"
|
||||
"List fvOptions",
|
||||
true // advanced
|
||||
);
|
||||
#endif
|
||||
|
||||
@ -47,6 +54,7 @@ argList::addBoolOption
|
||||
argList::addBoolOption
|
||||
(
|
||||
"listTurbulenceModels",
|
||||
"List turbulenceModels"
|
||||
"List turbulenceModels",
|
||||
true // advanced
|
||||
);
|
||||
#endif
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
bool listOptions = false ;
|
||||
bool listOptions = false;
|
||||
|
||||
if
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user