From a84b5267af55ef8c500a4eb2acfc80a33e56f996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=BCkki=20D=C3=A1niel?= Date: Thu, 28 Mar 2024 22:37:25 +0100 Subject: [PATCH] Fully customizable extraction target path. --- .../parser/src/cppmetricsparser.cpp | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/plugins/cpp_metrics/parser/src/cppmetricsparser.cpp b/plugins/cpp_metrics/parser/src/cppmetricsparser.cpp index 7c997068e..dd52156cf 100644 --- a/plugins/cpp_metrics/parser/src/cppmetricsparser.cpp +++ b/plugins/cpp_metrics/parser/src/cppmetricsparser.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include @@ -351,15 +350,15 @@ class MetricsExtractor const fs::path& CodeDir() const { return _code; } public: - MetricsExtractor(cc::parser::ParserContext& ctx_, const char* name_) : + MetricsExtractor(cc::parser::ParserContext& ctx_, const fs::path& path_) : _ctx(ctx_), - _root("/home/dani/Artifacts/Extract/"), - _code(), + _root(path_), + _code(_root / "Code/"), _cache() { - _root /= name_; - _code = _root / "Code/"; fs::create_directories(_code); + _root = fs::canonical(_root); + _code = fs::canonical(_code); } void Extract(model::CppAstNodeMetrics::Type type_, const char* name_) @@ -449,22 +448,21 @@ bool CppMetricsParser::parse() bool CppMetricsParser::extract() { - std::string sName; - const auto& varName = _ctx.options["extract-to"]; - if (varName.empty()) + std::string sExPath; + const auto& varExPath = _ctx.options["extract-to"]; + if (varExPath.empty()) { - std::cout << "\nExtraction name: "; - std::getline(std::cin, sName); + std::cout << "\nExtraction path: "; + std::getline(std::cin, sExPath); } else { - sName = varName.as(); + sExPath = varExPath.as(); } - boost::trim(sName); - if (!sName.empty()) + if (!sExPath.empty()) { - MetricsExtractor me(_ctx, sName.c_str()); + MetricsExtractor me(_ctx, sExPath); std::cout << "Extracting to: " << me.RootDir().c_str() << std::endl; typedef model::CppAstNodeMetrics::Type Type;