blob: 0d29dab83129329317366c5935ad36ad9bf94afc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#include <iostream>
#include <settings.h>
using namespace std;
int main(int argc, char *argv[])
{
KaZoe::Settings settings;
if(argc < 2)
{
std::cout << "Current settings:" << std::endl;
settings.forEach([](const SettingKey& key, const SettingValue& value) {
std::string head;
if(!key.first.empty())
{
head = "[" + key.first + "]";
}
std::cout << "> " << head << key.second << " = " << KaZoe::valueToStr(value) << std::endl;
});
}
else
{
std::string category;
std::string gkey = argv[1];
if(gkey.starts_with("["))
{
category = gkey.substr(1, gkey.find(']') - 1);
gkey = gkey.substr(gkey.find(']') + 1);
}
if(argc == 2)
{
std::cout << KaZoe::valueToStr(settings.get(gkey, category)) << std::endl;
}
else if(argc == 3)
{
std::string value = argv[2];
settings.set(gkey, KaZoe::makeValue(value), category);
}
}
return 0;
}
|