Recfactored and simplified more code

- Added function to convert color string to ansi color string
- Added `trim` and `join` utility functions
- Added initial plugin test case
- Implemented `config get` command to see config properties
- Improved logging functionality and removed duplicate logging functions
- Removed unused functions
- Fixed more styling issues
- Fixed some CLI commands not working correctly
- Fixed CLI documentation format
- Fixed some error handling issues
This commit is contained in:
David Allen 2023-06-18 10:47:05 -06:00
parent e48c54aa40
commit 02a4e879a8
21 changed files with 541 additions and 384 deletions

View file

@ -1,3 +1,7 @@
#pragma once
#include "colors.hpp"
#include <string>
#if GDPM_ENABLE_COLORS == 1
#define GDPM_COLOR_BLACK "\033[0;30m"
@ -16,24 +20,26 @@
#define GDPM_COLOR_LIGHT_PURPLE "\033[0;35m"
#define GDPM_COLOR_YELLOW "\033[0;33m"
#define GDPM_COLOR_WHITE "\033[0;37m"
#define GDPM_COLOR_RESET GDPM_COLOR_WHITE
#else
#define GDPM_COLOR_BLACK
#define GDPM_COLOR_BLUE
#define GDPM_COLOR_GREEN
#define GDPM_COLOR_CYAN
#define GDPM_COLOR_RED
#define GDPM_COLOR_PURPLE
#define GDPM_COLOR_BROWN
#define GDPM_COLOR_GRAY
#define GDPM_COLOR_DARK_GRAY
#define GDPM_COLOR_LIGHT_BLUE
#define GDPM_COLOR_LIGHT_GREEN
#define GDPM_COLOR_LIGHT_CYAN
#define GDPM_COLOR_LIGHT_RED
#define GDPM_COLOR_LIGHT_PURPLE
#define GDPM_COLOR_YELLOW
#define GDPM_COLOR_WHITE
#define GDPM_COLOR_BLACK ""
#define GDPM_COLOR_BLUE ""
#define GDPM_COLOR_GREEN ""
#define GDPM_COLOR_CYAN ""
#define GDPM_COLOR_RED ""
#define GDPM_COLOR_PURPLE ""
#define GDPM_COLOR_BROWN ""
#define GDPM_COLOR_GRAY ""
#define GDPM_COLOR_DARK_GRAY ""
#define GDPM_COLOR_LIGHT_BLUE ""
#define GDPM_COLOR_LIGHT_GREEN ""
#define GDPM_COLOR_LIGHT_CYAN ""
#define GDPM_COLOR_LIGHT_RED ""
#define GDPM_COLOR_LIGHT_PURPLE ""
#define GDPM_COLOR_YELLOW ""
#define GDPM_COLOR_WHITE ""
#define GDPM_COLOR_RESET GDPM_COLOR_WHITE
#endif
@ -42,4 +48,24 @@
#define GDPM_COLOR_LOG_INFO GDPM_COLOR_LOG_RESET
#define GDPM_COLOR_LOG_ERROR GDPM_COLOR_RED
#define GDPM_COLOR_LOG_DEBUG GDPM_COLOR_YELLOW
#define GDPM_COLOR_LOG_WARNING GDPM_COLOR_YELLOW
#define GDPM_COLOR_LOG_WARNING GDPM_COLOR_YELLOW
namespace gdpm::color{
inline std::string from_string(const std::string& color_name){
if (color_name == "red"){ return GDPM_COLOR_RED; }
else if (color_name == "yellow"){ return GDPM_COLOR_YELLOW; }
else if (color_name == "green"){ return GDPM_COLOR_GREEN; }
else if (color_name == "blue"){ return GDPM_COLOR_BLUE; }
else if (color_name == "brown"){ return GDPM_COLOR_BROWN; }
else if (color_name == "gray"){ return GDPM_COLOR_GRAY; }
else if (color_name == "black"){ return GDPM_COLOR_BLACK; }
else if (color_name == "purple"){ return GDPM_COLOR_PURPLE; }
else if (color_name == "gray"){ return GDPM_COLOR_DARK_GRAY; }
else if (color_name == "light-blue"){ return GDPM_COLOR_LIGHT_BLUE; }
else if (color_name == "light-green"){ return GDPM_COLOR_LIGHT_GREEN; }
else if (color_name == "light-cyan"){ return GDPM_COLOR_LIGHT_CYAN; }
else if (color_name == "light-red"){ return GDPM_COLOR_LIGHT_RED; }
else if (color_name == "light-purple"){ return GDPM_COLOR_LIGHT_PURPLE; }
return "";
}
}