mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Update and fix JSON writer (#183)
* Fixing the check of createKey in handleConfigSetCommand * Update schema-config.json * add overwrite option to configset command * add overwrite option to setConfig function * add overwrite option to setConfig function
This commit is contained in:
parent
e46d392ed1
commit
b9ad2977de
@ -931,8 +931,9 @@ void JsonClientConnection::handleConfigSetCommand(const Json::Value &message, co
|
||||
return;
|
||||
}
|
||||
|
||||
bool createKey = message.isMember("create");
|
||||
Json::Value hyperionConfig = _hyperion->getJsonConfig();
|
||||
bool createKey = message["create"].asBool();
|
||||
Json::Value hyperionConfig;
|
||||
message["overwrite"].asBool() ? createKey = true : hyperionConfig = _hyperion->getJsonConfig();
|
||||
nested::configSetCommand(message["config"], hyperionConfig, createKey);
|
||||
|
||||
JsonFactory::writeJson(_hyperion->getConfigFileName(), hyperionConfig);
|
||||
|
@ -20,6 +20,9 @@
|
||||
},
|
||||
"create": {
|
||||
"type" : "boolean"
|
||||
},
|
||||
"overwrite": {
|
||||
"type" : "boolean"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
@ -268,7 +268,7 @@ QString JsonConnection::getConfig(std::string type)
|
||||
return QString();
|
||||
}
|
||||
|
||||
void JsonConnection::setConfig(const std::string &jsonString, bool create)
|
||||
void JsonConnection::setConfig(const std::string &jsonString, bool create, bool overwrite)
|
||||
{
|
||||
// create command
|
||||
Json::Value command;
|
||||
@ -276,6 +276,7 @@ void JsonConnection::setConfig(const std::string &jsonString, bool create)
|
||||
command["subcommand"] = "setconfig";
|
||||
|
||||
command["create"] = create;
|
||||
command["overwrite"] = overwrite;
|
||||
Json::Value & config = command["config"];
|
||||
if (jsonString.size() > 0)
|
||||
{
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
/// @param jsonString The JSON String(s) to write
|
||||
/// @param create Specifies whether the nonexistent json string to be created
|
||||
///
|
||||
void setConfig(const std::string & jsonString, bool create);
|
||||
void setConfig(const std::string & jsonString, bool create, bool overwrite);
|
||||
|
||||
///
|
||||
/// Set the color transform of the leds
|
||||
|
@ -91,6 +91,7 @@ int main(int argc, char * argv[])
|
||||
SwitchParameter<> & argSchemaGet = parameters.add<SwitchParameter<> >(0x0, "schemaGet" , "Print the json schema for Hyperion configuration");
|
||||
StringParameter & argConfigSet = parameters.add<StringParameter>('W', "configSet", "Write to the actual loaded configuration file. Should be a Json object string.");
|
||||
SwitchParameter<> & argCreate = parameters.add<SwitchParameter<> >(0x0, "createkeys", "Create non exist Json Entry(s) in the actual loaded configuration file. Argument to use in combination with configSet.");
|
||||
SwitchParameter<> & argOverwriteConfig = parameters.add<SwitchParameter<> >(0x0, "overwrite", "Overwrite the actual loaded configuration file with the Json object string from configSet. Argument to use in combination with configSet.");
|
||||
|
||||
// set the default values
|
||||
argAddress.setDefault(defaultServerAddress.toStdString());
|
||||
@ -219,7 +220,7 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
else if (argConfigSet.isSet())
|
||||
{
|
||||
connection.setConfig(argConfigSet.getValue(), argCreate.isSet());
|
||||
connection.setConfig(argConfigSet.getValue(), argCreate.isSet(), argOverwriteConfig.isSet());
|
||||
}
|
||||
else if (colorModding)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user