LCOV - code coverage report
Current view: top level - include/esys/repo/exe - cmdmanifest.h (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 1 1 100.0 %
Date: 2026-11-07 22:18:26 Functions: 0 0 -

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/exe/cmdmanifest.h
       3             :  * \brief Manifest command
       4             :  *
       5             :  * \cond
       6             :  * __legal_b__
       7             :  *
       8             :  * Copyright (c) 2021-2022 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             : #pragma once
      19             : 
      20             : #include "esys/repo/esysrepo_defs.h"
      21             : #include "esys/repo/exe/cmd.h"
      22             : #include "esys/repo/git/commit.h"
      23             : #include "esys/repo/manifest/merge.h"
      24             : #include "esys/repo/manifest/parsemode.h"
      25             : 
      26             : #include <memory>
      27             : #include <ostream>
      28             : #include <vector>
      29             : 
      30             : namespace esys::repo::exe
      31             : {
      32             : 
      33             : /*! \class CmdManifest esys/repo/exe/cmdmanifest.h "esys/repo/exe/cmdmanifest.h"
      34             :  * \brief Manifest command
      35             :  */
      36             : class ESYSREPO_API CmdManifest : public Cmd
      37             : {
      38             : public:
      39             :     enum class Task
      40             :     {
      41             :         NOT_SET, //!< Not set
      42             :         REVISION_AS_HEAD, //!< Revision as head
      43             :         LIST_DIRS, //!< List dirs
      44             :         LIST_PROJECTS, //!< List projects
      45             :         ADD_DIR, //!< Add dir
      46             :         DEL_DIR, //!< Del dir
      47             :         MERGE, //!< Flatten-merge files (ADR-0038)
      48             :     };
      49             : 
      50          32 :     class ESYSREPO_API TaskDelDir
      51             :     {
      52             :     public:
      53             :         //! Constructor
      54             :         TaskDelDir();
      55             : 
      56             :         //! Set the name
      57             :         /*!
      58             :          * \param[in] name the name
      59             :          */
      60             :         void set_name(const std::string &name);
      61             :         const std::string &get_name() const;
      62             : 
      63             :     private:
      64             :         //!< \cond DOXY_IMPL
      65             :         std::string m_name;
      66             :         //!< \endcond
      67             :     };
      68             : 
      69             :     class ESYSREPO_API TaskAddDir : public TaskDelDir
      70             :     {
      71             :     public:
      72             :         //! Constructor
      73             :         TaskAddDir();
      74             : 
      75             :         //! Set the url ssh
      76             :         /*!
      77             :          * \param[in] url_ssh the url ssh
      78             :          */
      79             :         void set_url_ssh(const std::string &url_ssh);
      80             :         const std::string &get_url_ssh() const;
      81             : 
      82             :         //! Set the url https
      83             :         /*!
      84             :          * \param[in] url_https the url https
      85             :          */
      86             :         void set_url_https(const std::string &url_https);
      87             :         const std::string &get_url_https() const;
      88             : 
      89             :     private:
      90             :         //!< \cond DOXY_IMPL
      91             :         std::string m_url_ssh;
      92             :         std::string m_url_https;
      93             :         //!< \endcond
      94             :     };
      95             : 
      96             :     //! Default constructor
      97             :     CmdManifest();
      98             : 
      99             :     //! Destructor
     100             :     ~CmdManifest() override;
     101             : 
     102             :     //! Set the task
     103             :     /*!
     104             :      * \param[in] task the task
     105             :      */
     106             :     void set_task(Task task);
     107             : 
     108             :     //! Get the task
     109             :     /*!
     110             :      * \return the task
     111             :      */
     112             :     Task get_task() const;
     113             : 
     114             :     //! Set the task add dir
     115             :     /*!
     116             :      * \param[in] task_add_dir the task add dir
     117             :      */
     118             :     void set_task_add_dir(const TaskAddDir &task_add_dir);
     119             :     const TaskAddDir &get_task_add_dir() const;
     120             : 
     121             :     //! Set the task del dir
     122             :     /*!
     123             :      * \param[in] task_del_dir the task del dir
     124             :      */
     125             :     void set_task_del_dir(const TaskDelDir &task_del_dir);
     126             :     const TaskDelDir &get_task_del_dir() const;
     127             : 
     128             :     //! Set the dirs
     129             :     /*!
     130             :      * \param[in] dirs the dirs
     131             :      */
     132             :     void set_dirs(const std::string &dirs);
     133             :     const std::string &get_dirs() const;
     134             : 
     135             :     //! Set the output file
     136             :     /*!
     137             :      * \param[in] output_file the output file
     138             :      */
     139             :     void set_output_file(const std::string &output_file);
     140             :     const std::string &get_output_file() const;
     141             : 
     142             :     //! update revision as head
     143             :     Result update_revision_as_head();
     144             : 
     145             :     //! update revision as head
     146             :     /*!
     147             :      * \param[in] repo std::shared_ptr<manifest::Repository> repo
     148             :      */
     149             :     Result update_revision_as_head(std::shared_ptr<manifest::Repository> repo);
     150             : 
     151             :     //! do revision as head
     152             :     Result do_revision_as_head();
     153             : 
     154             :     //! do list dirs
     155             :     Result do_list_dirs();
     156             : 
     157             :     //! do list projects
     158             :     Result do_list_projects();
     159             : 
     160             :     //! do add dir
     161             :     Result do_add_dir();
     162             : 
     163             :     //! do del dir
     164             :     Result do_del_dir();
     165             : 
     166             :     //! Flatten-merge input files (ADR-0038)
     167             :     Result do_merge();
     168             : 
     169             :     void set_merge_inputs(const std::vector<std::string> &paths);
     170             :     const std::vector<std::string> &get_merge_inputs() const;
     171             : 
     172             :     void set_on_conflict(manifest::Merge::OnConflict on_conflict);
     173             :     manifest::Merge::OnConflict get_on_conflict() const;
     174             : 
     175             :     void set_merge_format(manifest::Merge::OutputFormat format);
     176             :     manifest::Merge::OutputFormat get_merge_format() const;
     177             : 
     178             :     void set_merge_parse_mode(manifest::ParseMode mode);
     179             :     manifest::ParseMode get_merge_parse_mode() const;
     180             : 
     181             : protected:
     182             :     //!< \cond DOXY_IMPL
     183             :     Result impl_run() override;
     184             : 
     185             : private:
     186             :     //!< \cond DOXY_IMPL
     187             :     Task m_task = Task::NOT_SET;
     188             :     std::string m_output_file;
     189             :     std::string m_dirs;
     190             :     TaskAddDir m_task_add_dir;
     191             :     TaskDelDir m_task_del_dir;
     192             :     std::vector<std::string> m_merge_inputs;
     193             :     manifest::Merge::OnConflict m_on_conflict = manifest::Merge::OnConflict::Fail;
     194             :     manifest::Merge::OutputFormat m_merge_format = manifest::Merge::OutputFormat::Native;
     195             :     manifest::ParseMode m_merge_parse_mode = manifest::k_default_parse_mode;
     196             :     //!< \endcond
     197             : };
     198             : 
     199             : } // namespace esys::repo::exe

Generated by: LCOV version 1.14