feat: add default config path #4

Merged
t.behrendt merged 6 commits from feat-add-default-config-path into main 2025-12-27 13:29:53 +01:00
Showing only changes of commit 3052bb199f - Show all commits

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 = ""; std::string configPath = "config.yaml";
int opt; int opt;
while ((opt = getopt(argc, argv, "c:")) != -1) while ((opt = getopt(argc, argv, "c:")) != -1)
{ {
@@ -67,14 +67,18 @@ std::string getConfigPathFromCliArguments(int argc, char *argv[])
configPath = optarg; configPath = optarg;
break; break;
default: default:
std::cout << "No config path provided. Using default config path: $HOME/.config/UsbMakroBoard.yaml\n"; std::cerr << "Usage: " << argv[0] << " [-c config_file_path]\n";
configPath = "$HOME/.config/UsbMakroBoard.yaml"; exit(EXIT_FAILURE);
} }
} }
return configPath; return configPath;
} }
YAML::Node loadConfig(const std::string &configPath)
{
return YAML::LoadFile(configPath);
}
int openDevice(const std::string &devicePath) int openDevice(const std::string &devicePath)
{ {
int fdKeyboard = open(devicePath.c_str(), O_RDONLY); int fdKeyboard = open(devicePath.c_str(), O_RDONLY);