LCOV - code coverage report
Current view: top level - src/esys/repo/cli - cmdmulti_cli.cpp (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 4 52 7.7 %
Date: 2026-09-26 15:38:18 Functions: 2 6 33.3 %

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/cli/cmdmulti_cli.cpp
       3             :  * \brief
       4             :  *
       5             :  * \cond
       6             :  * __legal_b__
       7             :  *
       8             :  * Copyright (c) 2023-2026 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/cmdmulti.h"
      20             : 
      21             : #include <esys/md/rend/styled_string.h>
      22             : 
      23             : #include <termcolor/termcolor.hpp>
      24             : 
      25             : #include <vector>
      26             : 
      27             : namespace esys::repo::cli
      28             : {
      29             : 
      30             : #include "esys/repo/cli/cmdmulti_doc.cpp"
      31             : 
      32          16 : CmdMulti::CmdMulti(AppBase *app)
      33          32 :     : BaseType(app, "multi", "Handle branches from multiple repositories")
      34             : {
      35          16 : }
      36             : 
      37          16 : CmdMulti::~CmdMulti() = default;
      38             : 
      39           0 : int CmdMulti::configure_cmd(CmdType &cmd)
      40             : {
      41           0 :     int task_count = 0;
      42           0 :     if (get_vm().count("capture"))
      43             :     {
      44           0 :         cmd.set_task(CmdType::Task::CAPTURE);
      45           0 :         ++task_count;
      46             :     }
      47           0 :     if (get_vm().count("show"))
      48             :     {
      49           0 :         cmd.set_task(CmdType::Task::SHOW);
      50           0 :         ++task_count;
      51             :     }
      52           0 :     if (get_vm().count("delete"))
      53             :     {
      54           0 :         cmd.set_task(CmdType::Task::DELETE);
      55           0 :         ++task_count;
      56             :     }
      57           0 :     if (get_vm().count("push"))
      58             :     {
      59           0 :         cmd.set_task(CmdType::Task::PUSH);
      60           0 :         ++task_count;
      61             :     }
      62           0 :     if (get_vm().count("abort"))
      63             :     {
      64           0 :         cmd.set_task(CmdType::Task::ABORT);
      65           0 :         ++task_count;
      66             :     }
      67           0 :     if (get_vm().count("continue"))
      68             :     {
      69           0 :         cmd.set_task(CmdType::Task::CONTINUE);
      70           0 :         ++task_count;
      71             :     }
      72           0 :     if (task_count != 1) return -1;
      73             : 
      74           0 :     cmd.set_dry_run(get_vm().count("dry-run") > 0);
      75           0 :     cmd.set_interactive(get_vm().count("inter") > 0);
      76           0 :     cmd.set_silent(get_vm().count("silent") > 0);
      77           0 :     if (get_vm().count("depends-scope"))
      78           0 :         cmd.set_capture_scope(CmdType::CaptureScope::DEPENDS);
      79             :     else
      80           0 :         cmd.set_capture_scope(CmdType::CaptureScope::ALL);
      81             : 
      82             :     return 0;
      83             : }
      84             : 
      85           0 : std::shared_ptr<po::options_description> CmdMulti::get_desc()
      86             : {
      87           0 :     auto desc = Cmd::get_desc();
      88           0 :     if (desc != nullptr) return desc;
      89             : 
      90           0 :     desc = std::make_shared<po::options_description>("Multi options");
      91             :     // clang-format off
      92           0 :     desc->add_options()
      93           0 :         ("capture,c", "capture divergent branches as an esysrepo git note")
      94           0 :         ("show,s", "show the captured branches")
      95           0 :         ("delete,d", "delete the captured branches (notes)")
      96           0 :         ("push,p", "push captured/live set: dependency-ordered branches then notes")
      97           0 :         ("abort", "abort an in-progress multi --push")
      98           0 :         ("continue", "continue an in-progress multi --push")
      99           0 :         ("dry-run", "print the plan without writing notes or pushing")
     100           0 :         ("inter,i", "interactive confirm when capture and live state disagree")
     101           0 :         ("silent", "accept capture override without prompting (CI)")
     102           0 :         ("depends-scope", "limit capture/live scan to depends-connected repos (ADR-0022)")
     103             :         ;
     104             :     // clang-format on
     105           0 :     Cmd::set_desc(desc);
     106           0 :     return desc;
     107           0 : }
     108             : 
     109           0 : int CmdMulti::print_doc(std::ostream &os)
     110             : {
     111           0 :     os << cmdmulti_doc_strings;
     112           0 :     return 0;
     113             : }
     114             : 
     115             : } // namespace esys::repo::cli

Generated by: LCOV version 1.14