Line data Source code
1 : /*! 2 : * \file esys/repo/cli/cmdinfo_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/cmdinfo.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/cmdinfo_doc.cpp" 33 : 34 17 : CmdInfo::CmdInfo(AppBase *app) 35 34 : : BaseType(app, "info", "Get info on the manifest branch, current branch or unmerged branches") 36 : { 37 17 : } 38 : 39 17 : CmdInfo::~CmdInfo() = default; 40 : 41 3 : std::shared_ptr<po::options_description> CmdInfo::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>("Info options"); 47 : // clang-format off 48 3 : desc->add_options() 49 3 : ("help,h", "produce help message") 50 3 : ("diff,d", po::value<bool>()->default_value(false)->implicit_value(true), 51 : "show full info and commit diff including remote" 52 : "branches") 53 3 : ("overview,o", po::value<bool>()->default_value(false)->implicit_value(true), "Show overview of all local commits") 54 3 : ("current-branch,b", po::value<bool>()->default_value(false)->implicit_value(true), "Consider only checked out branches") 55 3 : ("local-only,l", po::value<bool>()->default_value(false)->implicit_value(true), "Disable all remote operations") 56 : ; 57 : // clang-format on 58 6 : Cmd::set_desc(desc); 59 3 : return desc; 60 0 : } 61 : 62 5 : int CmdInfo::configure_cmd(CmdType &cmd) 63 : { 64 10 : if (get_vm()["diff"].as<bool>()) cmd.set_diff(true); 65 10 : if (get_vm()["overview"].as<bool>()) cmd.set_overview(true); 66 10 : if (get_vm()["current-branch"].as<bool>()) cmd.set_current_branch(true); 67 10 : if (get_vm()["local-only"].as<bool>()) cmd.set_local_only(true); 68 : 69 5 : return 0; 70 : } 71 : 72 0 : int CmdInfo::print_doc(std::ostream &os) 73 : { 74 0 : os << cmdinfo_doc_strings; 75 0 : return 0; 76 : } 77 : 78 : } // namespace esys::repo::cli