#include "yscan.h" #include "file.h" #include #include #include #include #include namespace fs = std::filesystem; using namespace std::string_literals; int yscan(int argc, char* argv[]) { try { std::string name {fs::current_path().stem().string()}; std::string sources; std::string test_sources; for (const auto& i: fs::directory_iterator(".")) { fs::path p{i.path().filename()}; if (is_compile_unit_source_by_extension(p)) { if (p.string().substr(0, 4) == "test") { test_sources += " " + p.string() + "\n"; } else { sources += " " + p.string() + "\n"; } } } if (!test_sources.empty()) { test_sources = fmt::format(R"( {} {} )", "test-"s + name, test_sources); } std::string contents {R"( {} {} {})"}; contents = fmt::format(contents, name, sources, test_sources); std::cout << contents << std::endl; } catch (const std::exception& ex) { std::cerr << "yscan: " << ex.what() << std::endl; return 1; } return 0; }