Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2012-2020 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 actions 40 : 41 : The templates generated by this tool are primarily for use with Toni Giorgino's VMD GUI. It may be 42 : useful however to use this tool as a quick aid memoir. 43 : 44 : \par Examples 45 : 46 : The following generates template input for the action DISTANCE. 47 : \verbatim 48 : plumed gentemplate --action DISTANCE 49 : \endverbatim 50 : 51 : 52 : */ 53 : //+ENDPLUMEDOC 54 : 55 0 : class GenTemplate: 56 : public CLTool 57 : { 58 : public: 59 : static void registerKeywords( Keywords& keys ); 60 : explicit GenTemplate(const CLToolOptions& co ); 61 : int main(FILE* in, FILE*out,Communicator& pc); 62 0 : string description()const { 63 0 : return "print out a template input for a particular action"; 64 : } 65 : }; 66 : 67 7356 : PLUMED_REGISTER_CLTOOL(GenTemplate,"gentemplate") 68 : 69 1839 : void GenTemplate::registerKeywords( Keywords& keys ) { 70 1839 : CLTool::registerKeywords( keys ); 71 7356 : keys.add("optional","--action","print the template for this particular action"); 72 5517 : keys.addFlag("--list",false,"print a list of the available actions"); 73 5517 : keys.addFlag("--include-optional",false,"also print optional modifiers"); 74 1839 : } 75 : 76 0 : GenTemplate::GenTemplate(const CLToolOptions& co ): 77 0 : CLTool(co) 78 : { 79 0 : inputdata=commandline; 80 0 : } 81 : 82 0 : int GenTemplate::main(FILE* in, FILE*out,Communicator& pc) { 83 : 84 : std::string action; 85 0 : bool list_templates=false; 86 0 : parseFlag("--list",list_templates); 87 : 88 0 : if(list_templates) { 89 0 : std::cerr<<actionRegister()<<"\n"; 90 : return 0; 91 0 : } else if(parse("--action",action)) { 92 : bool include_optional; 93 0 : parseFlag("--include-optional",include_optional); 94 0 : if( !actionRegister().printTemplate(action,include_optional) ) { 95 0 : error("there is no registered action named " + action); 96 0 : return 1; 97 : } 98 : } else return 1; 99 : 100 : 101 : 102 0 : return 0; 103 : } 104 : } 105 : 106 5517 : } // End of namespace