LCOV - code coverage report
Current view: top level - cltools - Info.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 33 43 76.7 %
Date: 2020-11-18 11:20:57 Functions: 9 11 81.8 %

          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 "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         452 : class Info:
      53             :   public CLTool
      54             : {
      55             : public:
      56             :   static void registerKeywords( Keywords& keys );
      57             :   explicit Info(const CLToolOptions& co );
      58             :   int main(FILE* in, FILE*out,Communicator& pc);
      59           0 :   string description()const {
      60           0 :     return "provide informations about plumed";
      61             :   }
      62             : };
      63             : 
      64        6904 : PLUMED_REGISTER_CLTOOL(Info,"info")
      65             : 
      66        1613 : void Info::registerKeywords( Keywords& keys ) {
      67        1613 :   CLTool::registerKeywords( keys );
      68        4839 :   keys.addFlag("--configuration",false,"prints the configuration file");
      69        4839 :   keys.addFlag("--root",false,"print the location of the root directory for the plumed source");
      70        4839 :   keys.addFlag("--user-doc",false,"print the location of user manual (html)");
      71        4839 :   keys.addFlag("--developer-doc",false,"print the location of user manual (html)");
      72        4839 :   keys.addFlag("--version",false,"print the version number");
      73        4839 :   keys.addFlag("--long-version",false,"print the version number (long version)");
      74        4839 :   keys.addFlag("--git-version",false,"print the version number (git version, if available)");
      75        1613 : }
      76             : 
      77         452 : Info::Info(const CLToolOptions& co ):
      78         452 :   CLTool(co)
      79             : {
      80         452 :   inputdata=commandline;
      81         452 : }
      82             : 
      83         452 : int Info::main(FILE* in, FILE*out,Communicator& pc) {
      84             : 
      85         904 :   bool printconfiguration; parseFlag("--configuration",printconfiguration);
      86         904 :   bool printroot; parseFlag("--root",printroot);
      87         904 :   bool printuserdoc; parseFlag("--user-doc",printuserdoc);
      88         904 :   bool printdeveloperdoc; parseFlag("--developer-doc",printdeveloperdoc);
      89         904 :   bool printversion; parseFlag("--version",printversion);
      90         904 :   bool printlongversion; parseFlag("--long-version",printlongversion);
      91         904 :   bool printgitversion; parseFlag("--git-version",printgitversion);
      92         878 :   if(printroot) fprintf(out,"%s\n",config::getPlumedRoot().c_str());
      93         478 :   if(printconfiguration) fprintf(out,"%s",config::getMakefile().c_str());
      94         452 :   if(printuserdoc) {
      95           0 :     std::string userdoc=config::getPlumedHtmldir()+"/user-doc/html/index.html";
      96           0 :     FILE *ff=std::fopen(userdoc.c_str(),"r");
      97           0 :     if(ff) std::fclose(ff);
      98           0 :     else userdoc="http://plumed.github.io/doc-v" + config::getVersion() + "/user-doc/html/index.html";
      99             :     fprintf(out,"%s\n",userdoc.c_str());
     100             :   }
     101         452 :   if(printdeveloperdoc) {
     102           0 :     std::string developerdoc=config::getPlumedHtmldir()+"/developer-doc/html/index.html";
     103           0 :     FILE *ff=std::fopen(developerdoc.c_str(),"r");
     104           0 :     if(ff) std::fclose(ff);
     105           0 :     else developerdoc="http://plumed.github.io/doc-v" + config::getVersion() + "/developer-doc/html/index.html";
     106             :     fprintf(out,"%s\n",developerdoc.c_str());
     107             :   }
     108         452 :   if(printversion) fprintf(out,"%s\n",config::getVersion().c_str());
     109         452 :   if(printlongversion) fprintf(out,"%s\n",config::getVersionLong().c_str());
     110         452 :   if(printgitversion) fprintf(out,"%s\n",config::getVersionGit().c_str());
     111             : 
     112         452 :   return 0;
     113             : }
     114             : 
     115             : 
     116             : 
     117             : }
     118        4839 : }

Generated by: LCOV version 1.13