feat: add default config path

This commit is contained in:
2025-12-27 10:04:38 +01:00
parent 0d0509b8f1
commit 6021ec89f5

View File

@@ -57,7 +57,7 @@ std::pair<int, int> mapKeyEventToRowColumn(int keyEventNumber, const std::unorde
std::string getConfigPathFromCliArguments(int argc, char *argv[]) std::string getConfigPathFromCliArguments(int argc, char *argv[])
{ {
std::string configPath = "config.yaml"; std::string configPath = "";
int opt; int opt;
while ((opt = getopt(argc, argv, "c:")) != -1) while ((opt = getopt(argc, argv, "c:")) != -1)
{ {
@@ -67,16 +67,12 @@ std::string getConfigPathFromCliArguments(int argc, char *argv[])
configPath = optarg; configPath = optarg;
break; break;
default: default:
std::cerr << "Usage: " << argv[0] << " [-c config_file_path]\n"; std::cout << "No config path provided. Using default config path: $HOME/.config/UsbMakroBoard.yaml\n";
exit(EXIT_FAILURE); configPath = "$HOME/.config/UsbMakroBoard.yaml";
} }
} }
return configPath;
}
YAML::Node loadConfig(const std::string &configPath) return configPath;
{
return YAML::LoadFile(configPath);
} }
int openDevice(const std::string &devicePath) int openDevice(const std::string &devicePath)