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-11 08:09:47 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 "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       11635 : PLUMED_REGISTER_CLTOOL(Info,"info")
      62             : 
      63        3473 : void Info::registerKeywords( Keywords& keys ) {
      64        3473 :   CLTool::registerKeywords( keys );
      65        6946 :   keys.addFlag("--configuration",false,"prints the configuration file");
      66        6946 :   keys.addFlag("--root",false,"print the location of the root directory for the plumed source");
      67        6946 :   keys.addFlag("--user-doc",false,"print the location of user manual (html)");
      68        6946 :   keys.addFlag("--developer-doc",false,"print the location of user manual (html)");
      69        6946 :   keys.addFlag("--version",false,"print the version number");
      70        6946 :   keys.addFlag("--long-version",false,"print the version number (long version)");
      71        6946 :   keys.addFlag("--git-version",false,"print the version number (git version, if available)");
      72        6946 :   keys.addFlag("--include-dir",false,"print the location of the include dir");
      73        6946 :   keys.addFlag("--soext",false,"print the extension of shared libraries (so or dylib)");
      74        3473 : }
      75             : 
      76        1216 : Info::Info(const CLToolOptions& co ):
      77        1216 :   CLTool(co)
      78             : {
      79        1216 :   inputdata=commandline;
      80        1216 : }
      81             : 
      82        1212 : int Info::main(FILE* in, FILE*out,Communicator& pc) {
      83             : 
      84        1212 :   bool printconfiguration; parseFlag("--configuration",printconfiguration);
      85        1212 :   bool printroot; parseFlag("--root",printroot);
      86        1212 :   bool printuserdoc; parseFlag("--user-doc",printuserdoc);
      87        1212 :   bool printdeveloperdoc; parseFlag("--developer-doc",printdeveloperdoc);
      88        1212 :   bool printversion; parseFlag("--version",printversion);
      89        1212 :   bool printlongversion; parseFlag("--long-version",printlongversion);
      90        1212 :   bool printgitversion; parseFlag("--git-version",printgitversion);
      91        1212 :   bool printincludedir; parseFlag("--include-dir",printincludedir);
      92        1212 :   bool printsoext; parseFlag("--soext",printsoext);
      93        1805 :   if(printroot) std::fprintf(out,"%s\n",config::getPlumedRoot().c_str());
      94        1239 :   if(printconfiguration) std::fprintf(out,"%s",config::getMakefile().c_str());
      95        1212 :   if(printincludedir) std::fprintf(out,"%s\n",config::getPlumedIncludedir().c_str());
      96        1212 :   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           0 :     if(ff) std::fclose(ff);
     100           0 :     else userdoc="http://www.plumed.org/doc-v" + config::getVersion() + "/user-doc/html/index.html";
     101             :     std::fprintf(out,"%s\n",userdoc.c_str());
     102             :   }
     103        1212 :   if(printdeveloperdoc) {
     104           0 :     std::string developerdoc=config::getPlumedHtmldir()+"/developer-doc/html/index.html";
     105           0 :     FILE *ff=std::fopen(developerdoc.c_str(),"r");
     106           0 :     if(ff) std::fclose(ff);
     107           0 :     else developerdoc="http://www.plumed.org/doc-v" + config::getVersion() + "/developer-doc/html/index.html";
     108             :     std::fprintf(out,"%s\n",developerdoc.c_str());
     109             :   }
     110        1212 :   if(printversion) std::fprintf(out,"%s\n",config::getVersion().c_str());
     111        1212 :   if(printlongversion) std::fprintf(out,"%s\n",config::getVersionLong().c_str());
     112        1212 :   if(printgitversion) std::fprintf(out,"%s\n",config::getVersionGit().c_str());
     113        1804 :   if(printsoext) std::fprintf(out,"%s\n",config::getSoExt().c_str());
     114             : 
     115        1212 :   return 0;
     116             : }
     117             : 
     118             : 
     119             : 
     120             : }
     121             : }

Generated by: LCOV version 1.15