stamen

Stamen - static menu generator
git clone git://git.dimitrijedobrota.com/stamen.git
Log | Files | Refs | README | LICENSE

commit 1e52edf6a7e7ee4e60c043bf4894ef3e9dce0076
parent c8ced3bdeaf1fe72949185cdc566b5fc69f11ddc
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sun, 12 Nov 2023 21:47:15 +0000

Add generator program to be used with many files

Diffstat:
MCMakeLists.txt | 2+-
Msrc/CMakeLists.txt | 4++++
Msrc/generate.cpp | 21+++------------------
3 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -3,7 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) project( Menu - VERSION 0.0.3 + VERSION 0.0.4 DESCRIPTION "Experimentation with dinamic menus" LANGUAGES CXX ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt @@ -20,6 +20,10 @@ set_target_properties(demo PROPERTIES add_executable(generate generate.cpp) +target_link_libraries(generate + PRIVATE menu +) + target_include_directories(generate PUBLIC ../include ) diff --git a/src/generate.cpp b/src/generate.cpp @@ -1,22 +1,7 @@ -#include "json.hpp" -#include <format> -#include <fstream> -#include <iostream> -#include <string> - -using json = nlohmann::json; +#include "menu.h" int main(const int argc, const char *argv[]) { - for (int i = 1; i < argc; i++) { - const char *filename = argv[i]; - for (const auto &menu : json::parse(std::fstream(filename))) { - std::cout << std::format("{}({}):\n", (std::string)menu["name"], - (std::string)menu["code"]); - for (const auto &item : menu["items"]) { - std::cout << std::format("* {}({})\n", (std::string)item["prompt"], - (std::string)item["callback"]); - } - } - } + for (int i = 1; i < argc; i++) Menu::read(argv[i]); + Menu::generate(); return 0; }