Icons: add JSON formatting support

This commit is contained in:
李通洲
2023-09-05 16:02:07 +08:00
parent 971a69ad1b
commit dfbfb88a45
2 changed files with 16 additions and 1 deletions
+15 -1
View File
@@ -32,7 +32,7 @@ void ffPrintIcons(FFIconsOptions* options)
void ffInitIconsOptions(FFIconsOptions* options)
{
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_ICONS_MODULE_NAME, ffParseIconsCommandOptions, ffParseIconsJsonObject, ffPrintIcons, NULL);
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_ICONS_MODULE_NAME, ffParseIconsCommandOptions, ffParseIconsJsonObject, ffPrintIcons, ffGenerateIconsJson);
ffOptionInitModuleArg(&options->moduleArgs);
}
@@ -67,3 +67,17 @@ void ffParseIconsJsonObject(FFIconsOptions* options, yyjson_val* module)
ffPrintError(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
}
}
void ffGenerateIconsJson(FF_MAYBE_UNUSED FFIconsOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
FF_STRBUF_AUTO_DESTROY icons = ffStrbufCreate();
const char* error = ffDetectIcons(&icons);
if (error)
{
yyjson_mut_obj_add_str(doc, module, "error", error);
return;
}
yyjson_mut_obj_add_strbuf(doc, module, "result", &icons);
}
+1
View File
@@ -9,3 +9,4 @@ void ffInitIconsOptions(FFIconsOptions* options);
bool ffParseIconsCommandOptions(FFIconsOptions* options, const char* key, const char* value);
void ffDestroyIconsOptions(FFIconsOptions* options);
void ffParseIconsJsonObject(FFIconsOptions* options, yyjson_val* module);
void ffGenerateIconsJson(FFIconsOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module);