LCOV - code coverage report
Current view: top level - cltools - Info.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 39 47 83.0 %
Date: 2024-10-18 13:59:31 Functions: 7 7 100.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-2023 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 "core/CLToolRegister.h"
      24             : #include "tools/Tools.h"
      25             : #include "config/Config.h"
      26             : #include <cstdio>
      27             : #include <string>
      28             : 
      29             : namespace PLMD {
      30             : namespace cltools {
      31             : 
      32             : //+PLUMEDOC TOOLS info
      33             : /*
      34             : This tool allows you to obtain information about your plumed version
      35             : 
      36             : You can specify the information you require using the following command line
      37             : arguments
      38             : 
      39             : \par Examples
      40             : 
      41             : The following command returns the root directory for your plumed distribution.
      42             : \verbatim
      43             : plumed info --root
      44             : \endverbatim
      45             : 
      46             : */
      47             : //+ENDPLUMEDOC
      48             : 
      49             : class Info:
      50             :   public CLTool
      51             : {
      52             : public:
      53             :   static void registerKeywords( Keywords& keys );
      54             :   explicit Info(const CLToolOptions& co );
      55             :   int main(FILE* in, FILE*out,Communicator& pc) override;
      56           4 :   std::string description()const override {
      57           4 :     return "provide informations about plumed";
      58             :   }
      59             : };
      60             : 
      61       18256 : PLUMED_REGISTER_CLTOOL(Info,"info")
      62             : 
      63        5316 : void Info::registerKeywords( Keywords& keys ) {
      64        5316 :   CLTool::registerKeywords( keys );
      65       10632 :   keys.addFlag("--configuration",false,"prints the configuration file");
      66       10632 :   keys.addFlag("--root",false,"print the location of the root directory for the plumed source");
      67       10632 :   keys.addFlag("--user-doc",false,"print the location of user manual (html)");
      68       10632 :   keys.addFlag("--developer-doc",false,"print the location of user manual (html)");
      69       10632 :   keys.addFlag("--version",false,"print the version number");
      70       10632 :   keys.addFlag("--long-version",false,"print the version number (long version)");
      71       10632 :   keys.addFlag("--git-version",false,"print the version number (git version, if available)");
      72       10632 :   keys.addFlag("--include-dir",false,"print the location of the include dir");
      73       10632 :   keys.addFlag("--soext",false,"print the extension of shared libraries (so or dylib)");
      74        5316 : }
      75             : 
      76        2308 : Info::Info(const CLToolOptions& co ):
      77        2308 :   CLTool(co)
      78             : {
      79        2308 :   inputdata=commandline;
      80        2308 : }
      81             : 
      82        2304 : int Info::main(FILE* in, FILE*out,Communicator& pc) {
      83             : 
      84        2304 :   bool printconfiguration; parseFlag("--configuration",printconfiguration);
      85        2304 :   bool printroot; parseFlag("--root",printroot);
      86        2304 :   bool printuserdoc; parseFlag("--user-doc",printuserdoc);
      87        2304 :   bool printdeveloperdoc; parseFlag("--developer-doc",printdeveloperdoc);
      88        2304 :   bool printversion; parseFlag("--version",printversion);
      89        2304 :   bool printlongversion; parseFlag("--long-version",printlongversion);
      90        2304 :   bool printgitversion; parseFlag("--git-version",printgitversion);
      91        2304 :   bool printincludedir; parseFlag("--include-dir",printincludedir);
      92        2304 :   bool printsoext; parseFlag("--soext",printsoext);
      93        3060 :   if(printroot) std::fprintf(out,"%s\n",config::getPlumedRoot().c_str());
      94        2344 :   if(printconfiguration) std::fprintf(out,"%s",config::getMakefile().c_str());
      95        2304 :   if(printincludedir) std::fprintf(out,"%s\n",config::getPlumedIncludedir().c_str());
      96        2304 :   if(printuserdoc) {
      97           0 :     std::string userdoc=config::getPlumedHtmldir()+"/user-doc/html/index.html";
      98           0 :     FILE *ff=std::fopen(userdoc.c_str(),"r");
      99             :     // no exception here
     100           0 :     if(ff) std::fclose(ff);
     101           0 :     else userdoc="http://www.plumed.org/doc-v" + config::getVersion() + "/user-doc/html/index.html";
     102             :     std::fprintf(out,"%s\n",userdoc.c_str());
     103             :   }
     104        2304 :   if(printdeveloperdoc) {
     105           0 :     std::string developerdoc=config::getPlumedHtmldir()+"/developer-doc/html/index.html";
     106           0 :     FILE *ff=std::fopen(developerdoc.c_str(),"r");
     107             :     // no exception here
     108           0 :     if(ff) std::fclose(ff);
     109           0 :     else developerdoc="http://www.plumed.org/doc-v" + config::getVersion() + "/developer-doc/html/index.html";
     110             :     std::fprintf(out,"%s\n",developerdoc.c_str());
     111             :   }
     112        2304 :   if(printversion) std::fprintf(out,"%s\n",config::getVersion().c_str());
     113        2304 :   if(printlongversion) std::fprintf(out,"%s\n",config::getVersionLong().c_str());
     114        2304 :   if(printgitversion) std::fprintf(out,"%s\n",config::getVersionGit().c_str());
     115        3812 :   if(printsoext) std::fprintf(out,"%s\n",config::getSoExt().c_str());
     116             : 
     117        2304 :   return 0;
     118             : }
     119             : 
     120             : 
     121             : 
     122             : }
     123             : }

Generated by: LCOV version 1.16