Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2012-2019 The plumed team
3 : (see the PEOPLE file at the root of the distribution for a list of names)
4 :
5 : See http://www.plumed.org for more information.
6 :
7 : This file is part of plumed, version 2.
8 :
9 : plumed is free software: you can redistribute it and/or modify
10 : it under the terms of the GNU Lesser General Public License as published by
11 : the Free Software Foundation, either version 3 of the License, or
12 : (at your option) any later version.
13 :
14 : plumed is distributed in the hope that it will be useful,
15 : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : GNU Lesser General Public License for more details.
18 :
19 : You should have received a copy of the GNU Lesser General Public License
20 : along with plumed. If not, see <http://www.gnu.org/licenses/>.
21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
22 : #include "CLTool.h"
23 : #include "CLToolRegister.h"
24 : #include "tools/Tools.h"
25 : //#include "PlumedConfig.h"
26 : #include "core/ActionRegister.h"
27 : #include <cstdio>
28 : #include <string>
29 : #include <vector>
30 : #include <iostream>
31 :
32 : using namespace std;
33 :
34 : namespace PLMD {
35 : namespace cltools {
36 :
37 : //+PLUMEDOC TOOLS gentemplate
38 : /*
39 : gentemplate is a tool that you can use to construct template inputs for the various
40 : actions
41 :
42 : The templates generated by this tool are primarily for use with Toni Giorgino's vmd gui. It may be
43 : useful however to use this tool as a quick aid memoir.
44 :
45 : \par Examples
46 :
47 : The following generates template input for the action DISTANCE.
48 : \verbatim
49 : plumed gentemplate --action DISTANCE
50 : \endverbatim
51 :
52 :
53 : */
54 : //+ENDPLUMEDOC
55 :
56 0 : class GenTemplate:
57 : public CLTool
58 : {
59 : public:
60 : static void registerKeywords( Keywords& keys );
61 : explicit GenTemplate(const CLToolOptions& co );
62 : int main(FILE* in, FILE*out,Communicator& pc);
63 0 : string description()const {
64 0 : return "print out a template input for a particular action";
65 : }
66 : };
67 :
68 6452 : PLUMED_REGISTER_CLTOOL(GenTemplate,"gentemplate")
69 :
70 1613 : void GenTemplate::registerKeywords( Keywords& keys ) {
71 1613 : CLTool::registerKeywords( keys );
72 6452 : keys.add("optional","--action","print the template for this particular action");
73 4839 : keys.addFlag("--list",false,"print a list of the available actions");
74 4839 : keys.addFlag("--include-optional",false,"also print optional modifiers");
75 1613 : }
76 :
77 0 : GenTemplate::GenTemplate(const CLToolOptions& co ):
78 0 : CLTool(co)
79 : {
80 0 : inputdata=commandline;
81 0 : }
82 :
83 0 : int GenTemplate::main(FILE* in, FILE*out,Communicator& pc) {
84 :
85 : std::string action;
86 0 : bool list_templates=false;
87 0 : parseFlag("--list",list_templates);
88 :
89 0 : if(list_templates) {
90 0 : std::cerr<<actionRegister()<<"\n";
91 : return 0;
92 0 : } else if(parse("--action",action)) {
93 : bool include_optional;
94 0 : parseFlag("--include-optional",include_optional);
95 0 : if( !actionRegister().printTemplate(action,include_optional) ) {
96 0 : error("there is no registered action named " + action);
97 0 : return 1;
98 : }
99 : } else return 1;
100 :
101 :
102 :
103 0 : return 0;
104 : }
105 : }
106 :
107 4839 : } // End of namespace
|