Start implementing conf command
This commit is contained in:
@@ -7,7 +7,7 @@ MKDIR_P=mkdir -p
|
||||
BIN=bin/
|
||||
OBJPATH=$(BIN)intermediates
|
||||
INCLUDES=
|
||||
OBJECTS=$(OBJPATH)/ConfigFile.o $(OBJPATH)/HFileGen.o $(OBJPATH)/IncludeDeps.o $(OBJPATH)/Makefile.o $(OBJPATH)/Utils.o $(OBJPATH)/main.o
|
||||
OBJECTS=$(OBJPATH)/CLI.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=
|
||||
@@ -33,21 +33,24 @@ $(OUTPUT): $(OBJECTS)
|
||||
install: all
|
||||
$(info Installing MakeGen to /usr/bin/)
|
||||
@cp $(OUTPUT) /usr/bin/makegen
|
||||
$(OBJPATH)/CLI.o : src/CLI.cpp src/CLI.h src/Common.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
|
||||
$(info -[16%]- $<)
|
||||
$(info -[28%]- $<)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
$(OBJPATH)/HFileGen.o : src/HFileGen.cpp src/FileUtils.h src/Common.h src/Utils.h src/ConfigFile.h src/HFileGen.h
|
||||
$(info -[33%]- $<)
|
||||
$(info -[42%]- $<)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
$(OBJPATH)/IncludeDeps.o : src/IncludeDeps.cpp src/Common.h src/IncludeDeps.h src/ConfigFile.h src/FileUtils.h src/Utils.h
|
||||
$(info -[50%]- $<)
|
||||
$(info -[57%]- $<)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
$(OBJPATH)/Makefile.o : src/Makefile.cpp src/IncludeDeps.h src/ConfigFile.h src/FileUtils.h src/Common.h src/Utils.h src/Makefile.h
|
||||
$(info -[66%]- $<)
|
||||
$(info -[71%]- $<)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
$(OBJPATH)/Utils.o : src/Utils.cpp src/FileUtils.h src/Common.h src/Utils.h src/ConfigFile.h
|
||||
$(info -[83%]- $<)
|
||||
$(info -[85%]- $<)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
$(OBJPATH)/main.o : src/main.cpp 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/CLI.h src/Common.h src/ConfigFile.h src/FileUtils.h src/Utils.h src/HFileGen.h src/Makefile.h src/Timer.h
|
||||
$(info -[100%]- $<)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#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 <command> [<args>] [--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;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
struct CLI
|
||||
{
|
||||
static void DisplayCLIHelp();
|
||||
static int Main(int argc, char** argv);
|
||||
};
|
||||
+2
-1
@@ -12,7 +12,7 @@
|
||||
// Release , should be backwards compatible with any minor version
|
||||
#define MAKEGEN_VERSION_RELEASE 1
|
||||
// Minor changes, should be compatible with any other minor version with same major and release.
|
||||
#define MAKEGEN_VERSION_MINOR 7
|
||||
#define MAKEGEN_VERSION_MINOR 8
|
||||
#define MAKEGEN_VERSION ("v" STR(MAKEGEN_VERSION_MAJOR) "." STR(MAKEGEN_VERSION_RELEASE) "." STR(MAKEGEN_VERSION_MINOR))
|
||||
|
||||
const static unsigned int FLAG_HELP = BIT(0);
|
||||
@@ -26,6 +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);
|
||||
|
||||
|
||||
#define LOG_INFO(...) Log(__VA_ARGS__); std::cout << std::endl
|
||||
|
||||
+9
-2
@@ -1,3 +1,4 @@
|
||||
#include "CLI.h"
|
||||
#include "Common.h"
|
||||
#include "ConfigFile.h"
|
||||
#include "FileUtils.h"
|
||||
@@ -22,8 +23,8 @@ void PrintHelp()
|
||||
LOG_INFO("");
|
||||
LOG_INFO(" Options:");
|
||||
LOG_INFO(" -h, --help Displays this information");
|
||||
LOG_INFO(" --conf Prompt the user to enter information to create config");
|
||||
LOG_INFO(" file");
|
||||
LOG_INFO(" conf Run config command with given parameters. To see more");
|
||||
LOG_INFO(" run makegen conf --help");
|
||||
LOG_INFO(" -v, --version Displays the version of this program");
|
||||
LOG_INFO(" -m,-a, make, all Generates a Makefile and runs");
|
||||
LOG_INFO(" make all");
|
||||
@@ -55,6 +56,8 @@ void GenMakefile(const ConfigFile& conf, unsigned int flags)
|
||||
|
||||
unsigned int ReadFlags(int argc, char** argv)
|
||||
{
|
||||
if(argc >= 2 && std::string(argv[1]) == "conf")
|
||||
return FLAG_CLI;
|
||||
unsigned int flags = 0;
|
||||
bool make = true;
|
||||
for(int i = 1;i<argc;i++)
|
||||
@@ -182,6 +185,10 @@ int main(int argc, char** argv)
|
||||
ConfigFile::Gen().Save();
|
||||
return 0;
|
||||
}
|
||||
if(flags & FLAG_CLI)
|
||||
{
|
||||
return CLI::Main(argc-1, &argv[1]);
|
||||
}
|
||||
std::map<std::string, ConfigFile> files{};
|
||||
auto conf = ConfigFile::GetConfigFile();
|
||||
if(conf)
|
||||
|
||||
Reference in New Issue
Block a user