From 17245655d4869e8dbd77c2d68ca9d2803774b509 Mon Sep 17 00:00:00 2001 From: Thraix Date: Thu, 10 Oct 2019 21:36:30 +0200 Subject: [PATCH] Add all config cli commands --- Makefile | 10 +- makegen.conf | 11 +- src/CLI.cpp | 48 ------ src/CLI.h | 7 - src/Common.h | 4 +- src/ConfigCLI.cpp | 362 +++++++++++++++++++++++++++++++++++++++++++++ src/ConfigCLI.h | 27 ++++ src/ConfigFile.cpp | 4 +- src/main.cpp | 19 +-- 9 files changed, 408 insertions(+), 84 deletions(-) delete mode 100644 src/CLI.cpp delete mode 100644 src/CLI.h create mode 100644 src/ConfigCLI.cpp create mode 100644 src/ConfigCLI.h diff --git a/Makefile b/Makefile index 441f379..75efbf5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# This Makefile was generated using MakeGen v1.1.7 made by Tim HÃ¥kansson +# This Makefile was generated using MakeGen v1.1.8 made by Tim HÃ¥kansson # and is licensed under MIT. Full source of the project can be found at # https://github.com/Thraix/MakeGen CC=@g++ @@ -7,7 +7,7 @@ MKDIR_P=mkdir -p BIN=bin/ OBJPATH=$(BIN)intermediates INCLUDES= -OBJECTS=$(OBJPATH)/CLI.o $(OBJPATH)/ConfigFile.o $(OBJPATH)/HFileGen.o $(OBJPATH)/IncludeDeps.o $(OBJPATH)/Makefile.o $(OBJPATH)/Utils.o $(OBJPATH)/main.o +OBJECTS=$(OBJPATH)/ConfigCLI.o $(OBJPATH)/ConfigFile.o $(OBJPATH)/HFileGen.o $(OBJPATH)/IncludeDeps.o $(OBJPATH)/Makefile.o $(OBJPATH)/Utils.o $(OBJPATH)/main.o CFLAGS=$(INCLUDES) -std=c++17 -c -w -g3 -D_DEBUG LIBDIR= LDFLAGS= @@ -31,9 +31,9 @@ $(OUTPUT): $(OBJECTS) $(info Generating output file) $(CO) $(OUTPUT) $(OBJECTS) $(LDFLAGS) $(LIBS) install: all - $(info Installing MakeGen to /usr/bin/) + $(info Installing Testing space to /usr/bin/) @cp $(OUTPUT) /usr/bin/makegen -$(OBJPATH)/CLI.o : src/CLI.cpp src/CLI.h src/Common.h src/ConfigFile.h +$(OBJPATH)/ConfigCLI.o : src/ConfigCLI.cpp src/Common.h src/ConfigCLI.h src/ConfigFile.h $(info -[14%]- $<) $(CC) $(CFLAGS) -o $@ $< $(OBJPATH)/ConfigFile.o : src/ConfigFile.cpp src/ConfigFile.h src/FileUtils.h src/Common.h src/Utils.h @@ -51,6 +51,6 @@ $(OBJPATH)/Makefile.o : src/Makefile.cpp src/IncludeDeps.h src/ConfigFile.h src/ $(OBJPATH)/Utils.o : src/Utils.cpp src/FileUtils.h src/Common.h src/Utils.h src/ConfigFile.h $(info -[85%]- $<) $(CC) $(CFLAGS) -o $@ $< -$(OBJPATH)/main.o : src/main.cpp src/CLI.h src/Common.h src/ConfigFile.h src/FileUtils.h src/Utils.h src/HFileGen.h src/Makefile.h src/Timer.h +$(OBJPATH)/main.o : src/main.cpp src/Common.h src/ConfigCLI.h src/ConfigFile.h src/FileUtils.h src/Utils.h src/HFileGen.h src/Makefile.h src/Timer.h $(info -[100%]- $<) $(CC) $(CFLAGS) -o $@ $< diff --git a/makegen.conf b/makegen.conf index 89366d7..c4c50a8 100644 --- a/makegen.conf +++ b/makegen.conf @@ -1,18 +1,19 @@ #libs #libdirs #includedirs -#srcdir -src #defines _DEBUG #compileflags +#dependencies +#srcdir +src/ #outputdir bin #projectname -MakeGen +Testing space #outputname makegen #executable true -#dependencies - +#generatehfile +false diff --git a/src/CLI.cpp b/src/CLI.cpp deleted file mode 100644 index 8040fe8..0000000 --- a/src/CLI.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "CLI.h" - -#include "Common.h" -#include "ConfigFile.h" - -void CLI::DisplayCLIHelp() -{ - LOG_INFO("MakeGen conf is used to create, modify and query the makegen.conf file."); - LOG_INFO(""); - LOG_INFO("Usage: makegen conf [] [--help] "); - LOG_INFO(""); - LOG_INFO("Generating config files"); - LOG_INFO(" gen Prompt the user to enter information to create config"); - LOG_INFO(""); - - LOG_INFO("Modifying config settings"); - LOG_INFO(" add Add values to config settings which support multiple arguments"); - LOG_INFO(" remove Remove values to config settings which support multiple"); - LOG_INFO(" arguments"); - LOG_INFO(" set Set value to config settings which support only one argument"); - LOG_INFO(""); - - LOG_INFO("Querying config settings"); - LOG_INFO(" get List all values of the config setting"); - // --------------------------------------------------------------------------------------| -} - -int CLI::Main(int argc, char** argv) -{ - // Do nothing - if(argc < 2 || std::string(argv[1]) == "--help") - { - DisplayCLIHelp(); - return 0; - } - std::string command = argv[1]; - if(command == "gen") - { - ConfigFile::Gen().Save(); - return 0; - } - else - { - LOG_ERROR("Unknown config command: ", command); - return 1; - } - return 0; -} diff --git a/src/CLI.h b/src/CLI.h deleted file mode 100644 index c7c592b..0000000 --- a/src/CLI.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -struct CLI -{ - static void DisplayCLIHelp(); - static int Main(int argc, char** argv); -}; diff --git a/src/Common.h b/src/Common.h index 40eb637..b9cf4dc 100755 --- a/src/Common.h +++ b/src/Common.h @@ -16,7 +16,7 @@ #define MAKEGEN_VERSION ("v" STR(MAKEGEN_VERSION_MAJOR) "." STR(MAKEGEN_VERSION_RELEASE) "." STR(MAKEGEN_VERSION_MINOR)) const static unsigned int FLAG_HELP = BIT(0); -const static unsigned int FLAG_GEN = BIT(1); +// const static unsigned int FLAG_GEN = BIT(1); const static unsigned int FLAG_VERSION = BIT(2); const static unsigned int FLAG_CLEAN = BIT(3); const static unsigned int FLAG_MAKE = BIT(4); @@ -26,7 +26,7 @@ const static unsigned int FLAG_REBUILD = BIT(7); const static unsigned int FLAG_SINGLE_THREAD = BIT(8); const static unsigned int FLAG_DEPENDENCY = BIT(9); const static unsigned int FLAG_SIMPLE = BIT(10); -const static unsigned int FLAG_CLI = BIT(11); +const static unsigned int FLAG_CONFIG = BIT(11); #define LOG_INFO(...) Log(__VA_ARGS__); std::cout << std::endl diff --git a/src/ConfigCLI.cpp b/src/ConfigCLI.cpp new file mode 100644 index 0000000..6bafe1f --- /dev/null +++ b/src/ConfigCLI.cpp @@ -0,0 +1,362 @@ +#include "ConfigCLI.h" + +#include "Common.h" +#include "ConfigFile.h" + +#include + +void ConfigCLI::DisplayCLIHelp() +{ + LOG_INFO("MakeGen conf is used to create, modify and query the makegen.conf file."); + LOG_INFO(""); + LOG_INFO("Usage: makegen conf [] [--help] "); + LOG_INFO(""); + LOG_INFO("Generating config files"); + LOG_INFO(" gen Prompt the user to enter information to create config"); + LOG_INFO(""); + + LOG_INFO("Modifying config settings"); + LOG_INFO(" add Add values to config settings which support multiple arguments"); + LOG_INFO(" remove Remove values to config settings which support multiple"); + LOG_INFO(" arguments"); + LOG_INFO(" set Set value to config settings which support only one argument"); + LOG_INFO(""); + + LOG_INFO("Querying config settings"); + LOG_INFO(" get Get value of the config setting"); +} + +void ConfigCLI::DisplayGenHelp() +{ + LOG_INFO("Generate a config file from prompts"); + LOG_INFO(""); + LOG_INFO("Usage: makegen conf gen