LCOV - code coverage report
Current view: top level - oks/apps - oks_clone_repository.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 37 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /**
       2              :  *  \file oks_clone_repository.cpp
       3              :  *
       4              :  *  This file is part of the OKS package.
       5              :  *  Author: <Igor.Soloviev@cern.ch>
       6              :  */
       7              : 
       8              : #include "oks/kernel.hpp"
       9              : 
      10              : #include <string.h>
      11              : #include <stdlib.h>
      12              : 
      13              : #include <boost/program_options.hpp>
      14              : 
      15              : using namespace dunedaq::oks;
      16              : 
      17              : int
      18            0 : main(int argc, char **argv)
      19              : {
      20            0 :   std::string config_version, user_dir, branch_name;
      21            0 :   bool verbose = false;
      22              : 
      23            0 :   try
      24              :     {
      25            0 :       boost::program_options::options_description desc("Clone and checkout oks repository.\n\n"
      26              :           "By default the master branch is checkout. The \"branch\" command line option can be used to specify particular one. A branch will be created, if does not exist yet.\n"
      27              :           "TDAQ_DB_VERSION process environment variable or \"version\" command line option can be used to specify particular version.\n"
      28              :           "The output directory can be specified via command line, otherwise temporal directory will be created and its name will be reported.\n"
      29              :           "If TDAQ_DB_USER_REPOSITORY process environment variable is set, the utility makes no effect.\n\n"
      30            0 :           "The command line options are");
      31              : 
      32            0 :       std::vector<std::string> app_types_list;
      33            0 :       std::vector<std::string> segments_list;
      34              : 
      35            0 :       desc.add_options()
      36            0 :         ("branch,b", boost::program_options::value<std::string>(&branch_name), "checkout or create given branch name")
      37            0 :         ("version,e", boost::program_options::value<std::string>(&config_version), "oks config version in type:value format, where type is \"hash\", \"date\" or \"tag\"")
      38            0 :         ("output-directory,o", boost::program_options::value<std::string>(&user_dir), "output directory; if not defined, create temporal")
      39            0 :         ("verbose,v", "print verbose information")
      40            0 :         ("help,h", "print help message");
      41              : 
      42            0 :       boost::program_options::variables_map vm;
      43            0 :       boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
      44              : 
      45            0 :       if (vm.count("help"))
      46              :         {
      47            0 :           std::cout << desc << std::endl;
      48            0 :           return EXIT_SUCCESS;
      49              :         }
      50              : 
      51            0 :       if (vm.count("verbose"))
      52            0 :         verbose = true;
      53              : 
      54            0 :       boost::program_options::notify(vm);
      55            0 :     }
      56            0 :   catch (std::exception& ex)
      57              :     {
      58            0 :       std::cerr << "Command line parsing errors occurred:\n" << ex.what() << std::endl;
      59            0 :       return EXIT_FAILURE;
      60            0 :     }
      61              : 
      62            0 :   if (!getenv("TDAQ_DB_USER_REPOSITORY"))
      63              :     {
      64            0 :       if(!user_dir.empty())
      65            0 :         setenv("TDAQ_DB_USER_REPOSITORY_PATH", user_dir.c_str(), 1);
      66              : 
      67            0 :       OksKernel k(user_dir.empty() && !verbose, verbose, false, true, config_version.empty() ? nullptr : config_version.c_str(), branch_name);
      68              : 
      69            0 :       if (!k.get_user_repository_root().empty())
      70              :         {
      71            0 :           k.unset_repository_created();
      72              : 
      73            0 :           if (user_dir.empty())
      74            0 :             std::cout << k.get_user_repository_root() << std::endl;
      75              :         }
      76            0 :     }
      77              : 
      78              :   return EXIT_SUCCESS;
      79            0 : }
        

Generated by: LCOV version 2.0-1