LCOV - code coverage report
Current view: top level - src/esys/repo/cli - cmdmanifest_cli.cpp (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 26 49 53.1 %
Date: 2026-08-01 10:43:40 Functions: 4 6 66.7 %

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/cli/cmdmanifest_cli.cpp
       3             :  * \brief
       4             :  *
       5             :  * \cond
       6             :  * __legal_b__
       7             :  *
       8             :  * Copyright (c) 2020-2023 Michel Gillet
       9             :  * Distributed under the MIT License.
      10             :  * (See accompanying file LICENSE.txt or
      11             :  * copy at https://opensource.org/licenses/MIT)
      12             :  *
      13             :  * __legal_e__
      14             :  * \endcond
      15             :  *
      16             :  */
      17             : 
      18             : #include "esys/repo/esysrepo_prec.h"
      19             : #include "esys/repo/cli/cmdmanifest.h"
      20             : 
      21             : #include <msword2md/cpp/string.h>
      22             : 
      23             : #include <termcolor/termcolor.hpp>
      24             : 
      25             : #include <boost/filesystem.hpp>
      26             : 
      27             : #include <vector>
      28             : 
      29             : namespace esys::repo::cli
      30             : {
      31             : 
      32             : #include "esys/repo/cli/cmdmanifest_doc.cpp"
      33             : 
      34          17 : CmdManifest::CmdManifest(AppBase *app)
      35          34 :     : BaseType(app, "manifest", "Manifest tools")
      36             : {
      37          17 : }
      38             : 
      39          17 : CmdManifest::~CmdManifest() = default;
      40             : 
      41           3 : std::shared_ptr<po::options_description> CmdManifest::get_desc()
      42             : {
      43           3 :     auto desc = Cmd::get_desc();
      44           3 :     if (desc != nullptr) return desc;
      45             : 
      46           3 :     desc = std::make_shared<po::options_description>("Manifest options");
      47             :     // clang-format off
      48           3 :     desc->add_options()
      49           3 :         ("help,h", "produce help message")
      50           3 :         ("revision-as-HEAD,r", "Save revisions as current HEAD")
      51           3 :         ("output-file,o", po::value<std::string>(), "File to save the manifest to")
      52           3 :         ("list-dirs,l", "List all manifest directories")
      53           3 :         ("list-projects,p", po::value<std::string>()->implicit_value(""),
      54             :             "List all projects from one or all manifest directories")
      55           3 :         ("add-dir,a", po::value<std::string>(), "Add a manifest directory <name> <ssh> <https>")
      56           3 :         ("del-dir,d", po::value<std::string>(), "Delete a manifest directory <name>")
      57             :         ;
      58             :     // clang-format on
      59           6 :     Cmd::set_desc(desc);
      60           3 :     return desc;
      61           0 : }
      62             : 
      63           5 : int CmdManifest::configure_cmd(CmdType &cmd)
      64             : {
      65          10 :     if (get_vm().count("revision-as-HEAD"))
      66           0 :         cmd.set_task(CmdType::Task::REVISION_AS_HEAD);
      67          10 :     else if (get_vm().count("list-dirs"))
      68           0 :         cmd.set_task(CmdType::Task::LIST_DIRS);
      69          10 :     else if (get_vm().count("list-projects"))
      70             :     {
      71           0 :         cmd.set_task(CmdType::Task::LIST_PROJECTS);
      72           0 :         cmd.set_dirs(get_vm()["list-projects"].as<std::string>());
      73             :     }
      74          10 :     else if (get_vm().count("add-dir"))
      75             :     {
      76           0 :         CmdType::TaskAddDir add_dir;
      77             : 
      78           0 :         add_dir.set_name(get_vm()["add-dir"].as<std::string>());
      79             : 
      80           0 :         for (auto const &url : get_sub_args())
      81             :         {
      82           0 :             if (url.find("ssh://") != std::string::npos)
      83           0 :                 add_dir.set_url_ssh(url);
      84           0 :             else if (url.find("https://") != std::string::npos)
      85           0 :                 add_dir.set_url_https(url);
      86             :             else
      87           0 :                 error("url not known protocol for '" + url + "'");
      88           0 :         }
      89             : 
      90           0 :         cmd.set_task_add_dir(add_dir);
      91           0 :     }
      92          10 :     else if (get_vm().count("del-dir"))
      93             :     {
      94           0 :         CmdType::TaskDelDir del_dir;
      95             : 
      96           0 :         del_dir.set_name(get_vm()["del-dir"].as<std::string>());
      97             : 
      98           0 :         cmd.set_task_del_dir(del_dir);
      99           0 :     }
     100          10 :     if (get_vm().count("output-file")) cmd.set_output_file(get_vm()["output-file"].as<std::string>());
     101             : 
     102           5 :     return 0;
     103             : }
     104             : 
     105           0 : int CmdManifest::print_doc(std::ostream &os)
     106             : {
     107           0 :     os << cmdmanifest_doc_strings;
     108           0 :     return 0;
     109             : }
     110             : 
     111             : } // namespace esys::repo::cli

Generated by: LCOV version 1.14