diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/ksettings.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cmd/ksettings.cpp b/cmd/ksettings.cpp new file mode 100644 index 0000000..0d29dab --- /dev/null +++ b/cmd/ksettings.cpp @@ -0,0 +1,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; +} |