All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Info.cpp
Go to the documentation of this file.
1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  Copyright (c) 2013 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-code.org for more information.
6 
7  This file is part of plumed, version 2.0.
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 "config/Config.h"
26 #include <cstdio>
27 #include <string>
28 #include <vector>
29 
30 using namespace std;
31 
32 namespace PLMD {
33 namespace cltools{
34 
35 //+PLUMEDOC TOOLS info
36 /*
37 This tool allows you to obtain information about your plumed version
38 
39 You can specify the information you require using the following command line
40 arguments
41 
42 \par Examples
43 
44 The following command returns the root directory for your plumed distribution.
45 \verbatim
46 plumed info --root
47 \endverbatim
48 
49 */
50 //+ENDPLUMEDOC
51 
52 class Info:
53 public CLTool
54 {
55 public:
56  static void registerKeywords( Keywords& keys );
57  Info(const CLToolOptions& co );
58  int main(FILE* in, FILE*out,Communicator& pc);
59  string description()const{
60  return "provide informations about plumed";
61  }
62 };
63 
64 PLUMED_REGISTER_CLTOOL(Info,"info")
65 
66 void Info::registerKeywords( Keywords& keys ){
67  CLTool::registerKeywords( keys );
68  keys.addFlag("--configuration",false,"prints the configuration file");
69  keys.addFlag("--root",false,"print the location of the root directory for the plumed source");
70  keys.addFlag("--user-doc",false,"print the location of user manual (html)");
71  keys.addFlag("--developer-doc",false,"print the location of user manual (html)");
72  keys.addFlag("--version",false,"print the version number");
73  keys.addFlag("--long-version",false,"print the version number (long version)");
74  keys.addFlag("--git-version",false,"print the version number (git version, if available)");
75 }
76 
77 Info::Info(const CLToolOptions& co ):
78 CLTool(co)
79 {
81 }
82 
83 int Info::main(FILE* in, FILE*out,Communicator& pc){
84 
85  bool printconfiguration; parseFlag("--configuration",printconfiguration);
86  bool printroot; parseFlag("--root",printroot);
87  bool printuserdoc; parseFlag("--user-doc",printuserdoc);
88  bool printdeveloperdoc; parseFlag("--developer-doc",printdeveloperdoc);
89  bool printversion; parseFlag("--version",printversion);
90  bool printlongversion; parseFlag("--long-version",printlongversion);
91  bool printgitversion; parseFlag("--git-version",printgitversion);
92  if(printroot) fprintf(out,"%s\n",config::getPlumedRoot().c_str());
93  if(printconfiguration) fprintf(out,"%s",config::getMakefile().c_str());
94  std::string userdoc=config::getPlumedRoot()+"user-doc/html/index.html";
95  std::string developerdoc=config::getPlumedRoot()+"developer-doc/html/index.html";
96  if(printuserdoc) fprintf(out,"%s\n",userdoc.c_str());
97  if(printdeveloperdoc) fprintf(out,"%s\n",developerdoc.c_str());
98  if(printversion) fprintf(out,"%s\n",config::getVersion().c_str());
99  if(printlongversion) fprintf(out,"%s\n",config::getVersionLong().c_str());
100  if(printgitversion) fprintf(out,"%s\n",config::getVersionGit().c_str());
101 
102  return 0;
103 }
104 
105 
106 
107 }
108 }
std::string getMakefile()
Definition: Config.cpp:50
std::string getPlumedRoot()
Definition: Config.cpp:34
int main(int argc, char **argv)
This main uses only the interface published in Plumed.h.
Definition: main.cpp:38
Class containing wrappers to MPI.
Definition: Communicator.h:44
string description() const
virtual function returning a one-line descriptor for the tool
Definition: Info.cpp:59
STL namespace.
std::string getVersionLong()
Definition: Config.cpp:42
std::string getVersion()
Definition: Config.cpp:38
This is the abstract base class to use for implementing new command line tool, within it there is inf...
Definition: CLTool.h:55
This class holds the keywords and their documentation.
Definition: Keywords.h:36
std::string getVersionGit()
Definition: Config.cpp:46
void parseFlag(const std::string &key, bool &t)
Find out whether one of the command line flags is present or not.
Definition: CLTool.cpp:51
enum PLMD::CLTool::@0 inputdata
How is the input specified on the command line or in an input file.
int main(FILE *in, FILE *out, Communicator &pc)
virtual function mapping to the specific main for each tool
Definition: Info.cpp:83