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 -------------------------------------------------------------------------------
11 License
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 
27 Application
28  foamHelp
29 
30 Group
31  grpMiscUtilities
32 
33 Description
34  Top level wrapper utility around foam help utilities
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #include "fvCFD.H"
39 #include "helpType.H"
40 
41 using namespace Foam;
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 int 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 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::error::throwing
bool throwing() const noexcept
Return the current exception throwing state (on or off)
Definition: error.H:169
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
helpType.H
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::helpType::New
static autoPtr< helpType > New(const word &helpTypeName)
Selector.
addRegionOption.H
Foam::FatalError
error FatalError
createNamedMesh.H
Required Variables.
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::error::message
string message() const
The accumulated error message.
Definition: error.C:319
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::autoPtr::reset
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:117
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
setRootCase.H
addToolOption.H
Foam::nl
constexpr char nl
Definition: Ostream.H:404
createTime.H
Foam::autoPtr::clear
void clear() noexcept
Same as reset(nullptr)
Definition: autoPtr.H:176
fvCFD.H
args
Foam::argList args(argc, argv)
Foam::error
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Definition: error.H:73