Simplify logging of help commands

This commit is contained in:
Thraix
2019-10-11 19:01:30 +02:00
parent 67de469181
commit 37d204fa9a
2 changed files with 127 additions and 120 deletions
+97 -92
View File
@@ -7,139 +7,144 @@
void ConfigCLI::DisplayCLIHelp() void ConfigCLI::DisplayCLIHelp()
{ {
LOG_INFO("MakeGen conf is used to create, modify and query the makegen.conf file."); LOG_INFO(1+(char*)R"(
LOG_INFO(""); MakeGen conf is used to create, modify and query the makegen.conf file.
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"); Usage: makegen conf <command> [<args>] [--help]
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"); Generating config files
LOG_INFO(" get Get value of the config setting"); gen Prompt the user to enter information to create config
Modifying config settings
add Add values to config settings which support multiple arguments
remove Remove values to config settings which support multiple
arguments
set Set value to config settings which support only one argument
Querying config settings
get Get value of the config setting)");
} }
void ConfigCLI::DisplayGenHelp() void ConfigCLI::DisplayGenHelp()
{ {
LOG_INFO("Generate a config file from prompts"); LOG_INFO(1+(char*)R"(
LOG_INFO(""); Generate a config file from prompts
LOG_INFO("Usage: makegen conf gen <option>");
LOG_INFO(""); Usage: makegen conf gen <option>
LOG_INFO("options:");
LOG_INFO(" prompt Prompt the user for all needed settings"); options:
LOG_INFO(" default Generate a default config file. Source directory is set to"); prompt Prompt the user for all needed settings
LOG_INFO(" src/, outputdir is set to bin/ and project name is set to"); default Generate a default config file. Source directory is set to
LOG_INFO(" the current directory name."); src/, outputdir is set to bin/ and project name is set to
the current directory name.)");
} }
void ConfigCLI::DisplayAddHelp() void ConfigCLI::DisplayAddHelp()
{ {
LOG_INFO("Add values to config settings which support multiple arguments"); LOG_INFO(1+(char*)R"(
LOG_INFO(""); Add values to config settings which support multiple arguments
LOG_INFO("Usage: makegen conf add <setting> <value> [<values>]");
LOG_INFO(""); Usage: makegen conf add <setting> <value> [<values>]
LOG_INFO("Valid settings are:");
LOG_INFO(" library Library"); Valid settings are:
LOG_INFO(" libdir Library directory"); library Library
LOG_INFO(" includedir Include directory"); libdir Library directory
LOG_INFO(" define Preprocessor define"); includedir Include directory
LOG_INFO(" cflag g++ compiler flags"); define Preprocessor define
LOG_INFO(" dependency Project which current project depends on"); cflag g++ compiler flags
dependency Project which current project depends on)");
} }
void ConfigCLI::DisplayRemoveHelp() void ConfigCLI::DisplayRemoveHelp()
{ {
LOG_INFO("Remove values to config settings which support multiple arguments"); LOG_INFO(1+(char*)R"(
LOG_INFO(""); Remove values to config settings which support multiple
LOG_INFO("Usage: makegen conf remove <setting> <value> [<values>]");
LOG_INFO(""); Usage: makegen conf remove <setting> <value> [<
LOG_INFO("Valid settings are:");
LOG_INFO(" library Library name"); Valid settings are
LOG_INFO(" libdir Library directory"); library Library name
LOG_INFO(" includedir Include directory"); libdir Library directory
LOG_INFO(" define Preprocessor define"); includedir Include directory
LOG_INFO(" cflag g++ compiler flags"); define Preprocessor define
LOG_INFO(" dependency Project which current project depends on"); cflag g++ compiler flags
dependency Project which current project depends on)");
} }
void ConfigCLI::DisplaySetHelp() void ConfigCLI::DisplaySetHelp()
{ {
LOG_INFO("Set value to config settings which only support one argument"); LOG_INFO(1+(char*)R"(
LOG_INFO(""); Set value to config settings which only support one argument
LOG_INFO("Usage: makegen conf set <setting> <value>");
LOG_INFO(""); Usage: makegen conf set <setting> <value>
LOG_INFO("Valid string settings are:");
LOG_INFO(" outputdir Directory of the compiled output"); Valid string settings are:
LOG_INFO(" output Name of the output executable/library"); outputdir Directory of the compiled output
LOG_INFO(" name Name of the project"); output Name of the output executable/library
LOG_INFO(" hfile Name of the generated project h-file"); name Name of the project
LOG_INFO(""); hfile Name of the generated project h-file
LOG_INFO("Valid boolean settings are:");
LOG_INFO(" executable Specifies if the project be compiled as executable or library"); Valid boolean settings are:
LOG_INFO(" shared Specifies if the library should be compiled as shared."); executable Specifies if the project be compiled as executable or library
LOG_INFO(" genhfile Specifies if MakeGen should generate a project h-file"); shared Specifies if the library should be compiled as shared.
LOG_INFO(""); genhfile Specifies if MakeGen should generate a project h-file
LOG_INFO("Boolean values can be set to either true/t/yes/y or false/f/no/n");
Boolean values can be set to either true/t/yes/y or false/f/no/n)");
} }
void ConfigCLI::DisplayGetHelp() void ConfigCLI::DisplayGetHelp()
{ {
LOG_INFO("Get value of the config setting"); LOG_INFO(1+(char*)R"(
LOG_INFO(""); Get value of the config setting
LOG_INFO("Usage: makegen conf get <setting>");
LOG_INFO(""); Usage: makegen conf get <setting>
LOG_INFO("Valid settings are:");
LOG_INFO(" library Library name"); Valid settings are:
LOG_INFO(" libdir Library directory"); library Library name
LOG_INFO(" includedir Include directory"); libdir Library directory
LOG_INFO(" define Preprocessor define"); includedir Include directory
LOG_INFO(" cflag g++ compiler flags"); define Preprocessor define
LOG_INFO(" dependency Project which current project depends on"); cflag g++ compiler flags
LOG_INFO(" outputdir Directory of the compiled output"); dependency Project which current project depends on
LOG_INFO(" output Name of the output executable/library"); outputdir Directory of the compiled output
LOG_INFO(" name Name of the project"); output Name of the output executable/library
LOG_INFO(" hfile Name of the generated project h-file"); name Name of the project
LOG_INFO(" executable Specifies if the project be compiled as executable or library"); hfile Name of the generated project h-file
LOG_INFO(" shared Specifies if the library should be compiled as shared."); executable Specifies if the project be compiled as executable or library
LOG_INFO(" genhfile Specifies if MakeGen should generate a project h-file"); shared Specifies if the library should be compiled as shared.
genhfile Specifies if MakeGen should generate a project h-file)");
} }
std::map<std::string, std::vector<std::string>*> ConfigCLI::GetSettingVectorMap(ConfigFile& config) std::map<std::string, std::vector<std::string>*> ConfigCLI::GetSettingVectorMap(ConfigFile& config)
{ {
return { return {
{"library",&config.libs}, {"library",&config.libs},
{"libdir",&config.libdirs}, {"libdir",&config.libdirs},
{"includedir",&config.includedirs}, {"includedir",&config.includedirs},
{"define",&config.defines}, {"define",&config.defines},
{"cflag",&config.flags}, {"cflag",&config.flags},
{"dependency",&config.dependencies} {"dependency",&config.dependencies}
}; };
} }
std::map<std::string, std::string*> ConfigCLI::GetSettingStringMap(ConfigFile& config) std::map<std::string, std::string*> ConfigCLI::GetSettingStringMap(ConfigFile& config)
{ {
return { return {
{"outputdir", &config.outputdir}, {"outputdir", &config.outputdir},
{"output", &config.outputname}, {"output", &config.outputname},
{"name", &config.projectname}, {"name", &config.projectname},
{"hfile", &config.hFile}, {"hfile", &config.hFile},
}; };
} }
std::map<std::string, bool*> ConfigCLI::GetSettingBoolMap(ConfigFile& config) std::map<std::string, bool*> ConfigCLI::GetSettingBoolMap(ConfigFile& config)
{ {
return { return {
{"executable", &config.executable}, {"executable", &config.executable},
{"shared", &config.shared}, {"shared", &config.shared},
{"genhfile", &config.generateHFile} {"genhfile", &config.generateHFile}
}; };
} }
+30 -28
View File
@@ -15,34 +15,36 @@
void PrintHelp() void PrintHelp()
{ {
LOG_INFO("MakeGen ", MAKEGEN_VERSION); LOG_INFO(1+(char*)R"(
LOG_INFO(""); MakeGen ", MAKEGEN_VERSIO
LOG_INFO("MakeGen is a utility tool to generate and run Makefiles in a simple manner.\nBy default it always compiles code with parallell jobs.");
LOG_INFO(""); MakeGen is a utility tool to generate and run Makefiles in a simple manner.
LOG_INFO("Usage: makegen [options]"); By default it always compiles code with parallell jobs.
LOG_INFO("");
LOG_INFO(" Options:"); Usage: makegen [options]
LOG_INFO(" -h, --help Displays this information");
LOG_INFO(" -v, --version Displays the version of this program"); Options:
LOG_INFO(" -m,-a, make, all Generates a Makefile and runs"); -h, --help Displays this information
LOG_INFO(" make all"); -v, --version Displays the version of this program
LOG_INFO(" -i, install Generates a Makefile and runs"); -m,-a, make, all Generates a Makefile and runs
LOG_INFO(" make all && make install"); make all
LOG_INFO(" -c, clean Generates a Makefile and runs"); -i, install Generates a Makefile and runs
LOG_INFO(" make clean"); make all && make install
LOG_INFO(" -r, rebuild Generates a Makefile and runs"); -c, clean Generates a Makefile and runs
LOG_INFO(" make clean && make all"); make clean
LOG_INFO(" -e, run, execute Generates a Makefile and runs"); -r, rebuild Generates a Makefile and runs
LOG_INFO(" make all && make run"); make clean && make all
LOG_INFO(" -s, single Runs additional makegen options as single thread"); -e, run, execute Generates a Makefile and runs
LOG_INFO(" (no --jobs=X flag)"); make all && make run
LOG_INFO(" --simple Creates a simple Makefile without include dependencies"); -s, single Runs additional makegen options as single thread
LOG_INFO(" (no --jobs=X flag)"); (no --jobs=X flag)
LOG_INFO(""); --simple Creates a simple Makefile without include dependencies
LOG_INFO(" If no option is given it will run \"make all\""); (no --jobs=X flag)
LOG_INFO("");
LOG_INFO(" If multiple make options are given it will run in the following order:"); If no option is given it will run \"make all\"
LOG_INFO(" clean all install run, rebuild will be translated to \"clean make\"");
If multiple make options are given it will run in the following order:
clean all install run, rebuild will be translated to \"clean make\")");
} }
void GenMakefile(const ConfigFile& conf, unsigned int flags) void GenMakefile(const ConfigFile& conf, unsigned int flags)