From 0b3acb991f11d9ace340f75bc2f8a454ea385fae Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 29 Oct 2025 17:16:47 +0100 Subject: Got to a first satisfying state for this boilerplate generator --- kel_cpp_boilerplate/c++/kel_cpp_boilerplate.cpp | 96 +++++++++++++++++++++++++ 1 file changed, 96 insertions(+) (limited to 'kel_cpp_boilerplate/c++/kel_cpp_boilerplate.cpp') diff --git a/kel_cpp_boilerplate/c++/kel_cpp_boilerplate.cpp b/kel_cpp_boilerplate/c++/kel_cpp_boilerplate.cpp index 972feb7..2399f61 100644 --- a/kel_cpp_boilerplate/c++/kel_cpp_boilerplate.cpp +++ b/kel_cpp_boilerplate/c++/kel_cpp_boilerplate.cpp @@ -1,10 +1,106 @@ #include + +#include "blueprints.hpp" + #include +#include +#include namespace kel { +saw::error_or write_to_file( + std::string_view file_path, + std::string_view file_content +){ + namespace fs = std::filesystem; + try { + auto fpath = fs::path(file_path); + if(fpath.has_parent_path()){ + fs::create_directories(fs::path(fpath).parent_path()); + } + + std::ofstream out(fpath, std::ios::binary); + if(not out){ + return saw::make_error("Couldn't create file"); + } + out.write(file_content.data(), static_cast(file_content.size())); + if(not out){ + return saw::make_error("Couldn't write to file"); + } + }catch(const std::exception& e){ + (void) e; + return saw::make_error("Couldn't create file somehow"); + } + + return saw::make_void(); +} + saw::error_or kel_main(int argc, char** argv){ (void) argc; (void) argv; + + namespace fs = std::filesystem; + + try { + fs::path cwd = fs::current_path(); + std::cout << "\nCurrent working is directory: " << cwd << "\n\n"; + + } catch (const std::exception& e) { + return saw::make_error("Couldn't get the working directory"); + } + { + std::string confirm; + std::cout << "Are you sure to proceed? Type 'yes' to continue: "; + std::getline(std::cin, confirm); + + if (confirm != "yes") { + std::cout<<"Didn't type \"yes\". Aborting..."<