From 70e37529ff5e5cb72548038179ef0ba3253621c5 Mon Sep 17 00:00:00 2001 From: Swarnava Mukherjee Date: Thu, 11 Jul 2024 23:48:05 +0530 Subject: [PATCH] fix: Add project name to README.md Signed-off-by: Swarnava Mukherjee --- headers/assets/scaffold_texts.hpp | 2 +- headers/workspace/scaffold.hpp | 1 + src/workspace/scaffold.cpp | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/headers/assets/scaffold_texts.hpp b/headers/assets/scaffold_texts.hpp index 6660b33..a858ea6 100644 --- a/headers/assets/scaffold_texts.hpp +++ b/headers/assets/scaffold_texts.hpp @@ -13,7 +13,7 @@ namespace assets::scaffold_texts { )"; const string README_MD = R"( - # Project name + # @PROJECT_NAME This project was made using `cbt` diff --git a/headers/workspace/scaffold.hpp b/headers/workspace/scaffold.hpp index 56774e5..d0403a3 100644 --- a/headers/workspace/scaffold.hpp +++ b/headers/workspace/scaffold.hpp @@ -9,6 +9,7 @@ namespace workspace::scaffold { using std::string; + const std::regex PROJECT_NAME_R{ "@PROJECT_NAME" }; const std::regex IMPORT_R{ "@FILE_NAME" }; const std::regex GUARD_R{ "@GUARD" }; const std::regex NAMESPACE_R{ "@NAMESPACE" }; diff --git a/src/workspace/scaffold.cpp b/src/workspace/scaffold.cpp index 2e2c373..7557ae7 100644 --- a/src/workspace/scaffold.cpp +++ b/src/workspace/scaffold.cpp @@ -103,7 +103,10 @@ namespace { return final_text; } else if (file_name.compare("README.md") == 0) { - return remove_raw_literal_indentations(README_MD); + const string text{ remove_raw_literal_indentations(README_MD) }; + const string with_project_name = std::regex_replace(text, PROJECT_NAME_R, project_name); + + return with_project_name; } else if (file_name.compare("project.cfg") == 0) { using namespace workspace::project_config;