foamHelp.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2012-2014 OpenFOAM Foundation
9 Copyright (C) 2017-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Application
28 foamHelp
29
30Group
31 grpMiscUtilities
32
33Description
34 Top level wrapper utility around foam help utilities
35
36\*---------------------------------------------------------------------------*/
37
38#include "fvCFD.H"
39#include "helpType.H"
40
41using namespace Foam;
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45int main(int argc, char *argv[])
46{
47 #include "addRegionOption.H"
48 #include "addToolOption.H"
49
50 // Intercept request for any -option (eg, -doc, -help)
51 // when it is the first argument
52 if (argc > 1 && '-' == *argv[1])
53 {
54 #include "setRootCase.H"
55 }
56 else if (argc < 2)
57 {
59 << "No help utility has been supplied" << nl
60 << exit(FatalError);
61 }
62
63 word utilityName(argv[1]);
64 autoPtr<helpType> utility;
65
66 const bool oldThrowingErr = FatalError.throwing(true);
67 try
68 {
69 utility.reset(helpType::New(utilityName));
70 }
71 catch (const Foam::error& err)
72 {
73 utility.clear();
74
76 << err.message().c_str() << nl
77 << exit(FatalError);
78 }
79 FatalError.throwing(oldThrowingErr);
80
81 utility().init();
82
83 #include "setRootCase.H"
84 #include "createTime.H"
85 #include "createNamedMesh.H"
86
87 utility().execute(args, mesh);
88
89 Info<< "\nEnd\n" << endl;
90
91 return 0;
92}
93
94
95// ************************************************************************* //
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
void clear() noexcept
Same as reset(nullptr)
Definition: autoPtr.H:176
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:117
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Definition: error.H:77
string message() const
The accumulated error message.
Definition: error.C:319
bool throwing() const noexcept
Return the current exception throwing state (on or off)
Definition: error.H:169
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
Required Variables.
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
Foam::argList args(argc, argv)