mirror of https://github.com/SeanOMik/swm.git
Create simple configuration file
This commit is contained in:
parent
42e1519091
commit
fc5159df02
|
@ -1,2 +1,4 @@
|
|||
.cache
|
||||
build
|
||||
build
|
||||
|
||||
config.toml
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"cmake.debugConfig": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <toml/parser.hpp>
|
||||
#include <toml/value.hpp>
|
||||
|
||||
#include "programs_config.h"
|
||||
|
||||
class Config {
|
||||
public:
|
||||
ProgramsConfig programs;
|
||||
|
||||
Config(const std::string& config_path) {
|
||||
toml::value toml = toml::parse(config_path);
|
||||
|
||||
programs = ProgramsConfig(toml["programs"]);
|
||||
}
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <toml.hpp>
|
||||
#include <toml/parser.hpp>
|
||||
#include <toml/value.hpp>
|
||||
|
||||
class ProgramsConfig {
|
||||
public:
|
||||
std::string terminal;
|
||||
std::string launcher;
|
||||
|
||||
/* ProgramsConfig(const std::string& config_path) : ProgramsConfig(toml::parse(config_path)) {
|
||||
|
||||
} */
|
||||
|
||||
ProgramsConfig() = default;
|
||||
|
||||
ProgramsConfig(toml::value& toml_config) {
|
||||
terminal = toml_config["terminal"].as_string();
|
||||
launcher = toml_config["launcher"].as_string();
|
||||
}
|
||||
};
|
|
@ -1,6 +1,11 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "config/config.h"
|
||||
|
||||
int main() {
|
||||
std::cout << "hello world" << std::endl;
|
||||
Config config("config.toml");
|
||||
|
||||
std::cout << "Terminal: \"" << config.programs.terminal << "\" - Launcher: \"" << config.programs.launcher << "\"" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue