#include "CommandLineArgs.h" #include "Directory.h" #include #include #include #include class GeneratorConfig { }; class ContentFile { public: ContentFile(const std::string& filename) : mFilename(filename) { } std::string getFilename() const { return mFilename; } protected: std::string mFilename; }; class ContentPage : public ContentFile { public: ContentPage(const std::string& filename) : ContentFile(filename) { } }; class ContentArticle : public ContentFile { public: ContentArticle(const std::string& filename) : ContentFile(filename) { } }; class WebsiteGenerator { public: void findProject(const std::string& searchPath) { const auto config_path = std::filesystem::path(searchPath) / "config.toml"; if (std::filesystem::exists(config_path)) { mProjectPath = searchPath; std::cout << "Found config.toml in " << searchPath << std::endl; } } void readConfig() { } void parseContentFiles() { const auto pages_files = Directory::getFilesWithExtension(getPagesPath(), ".md"); for (const auto& path : pages_files) { mPages.push_back(ContentPage(path)); } const auto article_files = Directory::getFilesWithExtension(getArticlesPath(), ".md"); for (const auto& path : article_files) { mArticles.push_back(ContentArticle(path)); } for(const auto& page : mPages) { std::cout << "Got page " << page.getFilename() << std::endl; } for(const auto& article : mArticles) { std::cout << "Got article " << article.getFilename() << std::endl; } } void parseTemplateFiles() { } void doSubstitutions() { } void write() { } private: Path getContentPath() const { return mProjectPath / "content"; } Path getPagesPath() const { return getContentPath() / "pages"; } Path getArticlesPath() const { return getContentPath() / "articles"; } std::filesystem::path mProjectPath; GeneratorConfig mConfig; std::vector mPages; std::vector mArticles; }; int main(int argc, char *argv[]) { auto args = CommandLineArgs::Create(); args->process(argc, argv); args->recordLaunchPath(); WebsiteGenerator generator; generator.findProject(args->getArg(1)); generator.readConfig(); // Find and process project files generator.parseContentFiles(); // Find template files // Substitute template files return 0; }