mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 17:41:41 +01:00
JsonConfig: code simplify
This commit is contained in:
@@ -93,33 +93,27 @@ bool ffParseCommandJsonObject(FFinstance* instance, const char* type, JSONCData*
|
||||
FFCommandOptions __attribute__((__cleanup__(ffDestroyCommandOptions))) options;
|
||||
ffInitCommandOptions(&options);
|
||||
|
||||
if (module)
|
||||
FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val)
|
||||
{
|
||||
struct lh_entry* entry;
|
||||
lh_foreach(data->ffjson_object_get_object(module), entry)
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
if (strcasecmp(key, "shell") == 0)
|
||||
{
|
||||
const char* key = (const char *)lh_entry_k(entry);
|
||||
if (strcasecmp(key, "type") == 0)
|
||||
continue;
|
||||
json_object* val = (struct json_object *)lh_entry_v(entry);
|
||||
|
||||
if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
if (strcasecmp(key, "shell") == 0)
|
||||
{
|
||||
ffStrbufSetS(&options.shell, data->ffjson_object_get_string(val));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcasecmp(key, "text") == 0)
|
||||
{
|
||||
ffStrbufSetS(&options.text, data->ffjson_object_get_string(val));
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
ffStrbufSetS(&options.shell, data->ffjson_object_get_string(val));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcasecmp(key, "text") == 0)
|
||||
{
|
||||
ffStrbufSetS(&options.text, data->ffjson_object_get_string(val));
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(instance, FF_COMMAND_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
|
||||
ffPrintCommand(instance, &options);
|
||||
|
||||
Reference in New Issue
Block a user