From c187e9b523f78e8dc2a1d1637420e5f760404d67 Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Thu, 8 Jun 2017 16:07:58 +0100 Subject: [PATCH] ENH: foamHelp - minro refactoring to enable use of foamHelp -help option --- .../miscellaneous/foamHelp/addToolOption.H | 10 ++++++++++ .../utilities/miscellaneous/foamHelp/foamHelp.C | 13 ++++++++++--- .../foamHelp/helpTypes/helpBoundary/helpBoundary.C | 2 -- .../helpFunctionObject/helpFunctionObject.C | 2 -- .../foamHelp/helpTypes/helpSolver/helpSolver.C | 1 - 5 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 applications/utilities/miscellaneous/foamHelp/addToolOption.H diff --git a/applications/utilities/miscellaneous/foamHelp/addToolOption.H b/applications/utilities/miscellaneous/foamHelp/addToolOption.H new file mode 100644 index 00000000000..71aa0711794 --- /dev/null +++ b/applications/utilities/miscellaneous/foamHelp/addToolOption.H @@ -0,0 +1,10 @@ +argList::validArgs.append("tool"); +const wordList opts(helpType::dictionaryConstructorTablePtr_->sortedToc()); + +string note = "Valid <tool> options include:"; +forAll(opts, i) +{ + note = note + ' ' + opts[i]; +} + +argList::notes.append(note); diff --git a/applications/utilities/miscellaneous/foamHelp/foamHelp.C b/applications/utilities/miscellaneous/foamHelp/foamHelp.C index d4d145ee218..a0e7097e4f9 100644 --- a/applications/utilities/miscellaneous/foamHelp/foamHelp.C +++ b/applications/utilities/miscellaneous/foamHelp/foamHelp.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,6 +42,14 @@ using namespace Foam; int main(int argc, char *argv[]) { #include "addRegionOption.H" + #include "addToolOption.H" + + // Intercept request for help + if ((argc > 0) && (strcmp(argv[1], "-help") == 0)) + { + #include "setRootCase.H" + } + if (argc < 2) { FatalError @@ -49,8 +57,7 @@ int main(int argc, char *argv[]) << exit(FatalError); } - const word utilityName = argv[1]; - + word utilityName = argv[1]; Foam::autoPtr<Foam::helpType> utility ( helpType::New(utilityName) diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundary.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundary.C index 5052b76a14f..3e3931c4c30 100644 --- a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundary.C +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundary.C @@ -62,8 +62,6 @@ void Foam::helpTypes::helpBoundary::init() { helpType::init(); - argList::validArgs.append("boundary"); - argList::addOption ( "field", diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpFunctionObject/helpFunctionObject.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpFunctionObject/helpFunctionObject.C index c42a430a061..81fca4a9184 100644 --- a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpFunctionObject/helpFunctionObject.C +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpFunctionObject/helpFunctionObject.C @@ -61,8 +61,6 @@ Foam::helpTypes::helpFunctionObject::~helpFunctionObject() void Foam::helpTypes::helpFunctionObject::init() { helpType::init(); - - argList::validArgs.append("functionObject"); } diff --git a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpSolver/helpSolver.C b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpSolver/helpSolver.C index cac59967c31..ac628c09c67 100644 --- a/applications/utilities/miscellaneous/foamHelp/helpTypes/helpSolver/helpSolver.C +++ b/applications/utilities/miscellaneous/foamHelp/helpTypes/helpSolver/helpSolver.C @@ -63,7 +63,6 @@ void Foam::helpTypes::helpSolver::init() { helpType::init(); - argList::validArgs.append("solver"); argList::addBoolOption ( "read", -- GitLab