Global: improve support of --help *-format

Also fix some bugs found when refactoring
This commit is contained in:
李通洲
2023-10-07 13:40:40 +08:00
parent 23d2cc3fdc
commit 12208b2c7c
113 changed files with 746 additions and 557 deletions
+14 -3
View File
@@ -5,7 +5,7 @@
#include "util/stringUtils.h"
#define FF_POWERADAPTER_DISPLAY_NAME "Power Adapter"
#define FF_POWERADAPTER_MODULE_ARGS 5
#define FF_POWERADAPTER_NUM_FORMAT_ARGS 5
void ffPrintPowerAdapter(FFPowerAdapterOptions* options)
{
@@ -42,7 +42,7 @@ void ffPrintPowerAdapter(FFPowerAdapterOptions* options)
}
else
{
ffPrintFormat(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_POWERADAPTER_MODULE_ARGS, (FFformatarg[]){
ffPrintFormat(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_POWERADAPTER_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_INT, &result->watts},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer},
@@ -62,7 +62,7 @@ void ffPrintPowerAdapter(FFPowerAdapterOptions* options)
void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options)
{
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_POWERADAPTER_MODULE_NAME, ffParsePowerAdapterCommandOptions, ffParsePowerAdapterJsonObject, ffPrintPowerAdapter, ffGeneratePowerAdapterJson);
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_POWERADAPTER_MODULE_NAME, ffParsePowerAdapterCommandOptions, ffParsePowerAdapterJsonObject, ffPrintPowerAdapter, ffGeneratePowerAdapterJson, ffPrintPowerAdapterHelpFormat);
ffOptionInitModuleArg(&options->moduleArgs);
}
@@ -126,3 +126,14 @@ void ffGeneratePowerAdapterJson(FF_MAYBE_UNUSED FFPowerAdapterOptions* options,
}
}
}
void ffPrintPowerAdapterHelpFormat(void)
{
ffPrintModuleFormatHelp(FF_POWERADAPTER_MODULE_NAME, "{1}W", FF_POWERADAPTER_NUM_FORMAT_ARGS, (const char* []) {
"PowerAdapter watts",
"PowerAdapter name",
"PowerAdapter manufacturer",
"PowerAdapter model",
"PowerAdapter description"
});
}
+1
View File
@@ -10,3 +10,4 @@ bool ffParsePowerAdapterCommandOptions(FFPowerAdapterOptions* options, const cha
void ffDestroyPowerAdapterOptions(FFPowerAdapterOptions* options);
void ffParsePowerAdapterJsonObject(FFPowerAdapterOptions* options, yyjson_val* module);
void ffGeneratePowerAdapterJson(FFPowerAdapterOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module);
void ffPrintPowerAdapterHelpFormat(void);