Start implementing conf command
This commit is contained in:
+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