forked from plumed/plumed2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Manual.cpp
101 lines (81 loc) · 3.25 KB
/
Manual.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copyright (c) 2012-2020 The plumed team
(see the PEOPLE file at the root of the distribution for a list of names)
See http://www.plumed.org for more information.
This file is part of plumed, version 2.
plumed is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
plumed is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with plumed. If not, see <http://www.gnu.org/licenses/>.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#include "CLTool.h"
#include "CLToolRegister.h"
#include "tools/Tools.h"
#include "config/Config.h"
#include "core/ActionRegister.h"
#include <cstdio>
#include <string>
#include <iostream>
namespace PLMD {
namespace cltools {
//+PLUMEDOC TOOLS manual
/*
manual is a tool that you can use to construct the manual page for
a particular action
The manual constructed by this action is in html. In all probability you will never need to use this
tool. However, it is used within the scripts that generate the html manual for PLUMED. If you need to use this
tool outside those scripts the input is specified using the following command line arguments.
\par Examples
The following generates the html manual for the action DISTANCE.
\verbatim
plumed manual --action DISTANCE
\endverbatim
*/
//+ENDPLUMEDOC
class Manual:
public CLTool
{
public:
static void registerKeywords( Keywords& keys );
explicit Manual(const CLToolOptions& co );
int main(FILE* in, FILE*out,Communicator& pc) override;
std::string description()const override {
return "print out a description of the keywords for an action in html";
}
};
PLUMED_REGISTER_CLTOOL(Manual,"manual")
void Manual::registerKeywords( Keywords& keys ) {
CLTool::registerKeywords( keys );
keys.add("compulsory","--action","print the manual for this particular action");
keys.addFlag("--vim",false,"print the keywords in vim syntax");
keys.addFlag("--spelling",false,"print a list of the keywords and component names for the spell checker");
}
Manual::Manual(const CLToolOptions& co ):
CLTool(co)
{
inputdata=commandline;
}
int Manual::main(FILE* in, FILE*out,Communicator& pc) {
std::string action;
if( !parse("--action",action) ) return 1;
std::cerr<<"LIST OF DOCUMENTED ACTIONS:\n";
std::cerr<<actionRegister()<<"\n";
std::cerr<<"LIST OF DOCUMENTED COMMAND LINE TOOLS:\n";
std::cerr<<cltoolRegister()<<"\n\n";
bool vimout; parseFlag("--vim",vimout);
bool spellout; parseFlag("--spelling",spellout);
if( vimout && spellout ) error("can only use one of --vim and --spelling at a time");
if( !actionRegister().printManual(action,vimout,spellout) && !cltoolRegister().printManual(action,spellout) ) {
fprintf(stderr,"specified action is not registered\n");
return 1;
}
return 0;
}
} // End of namespace
}