Global: support for named format arguments

Fix #796
This commit is contained in:
Carter Li
2024-05-27 16:41:37 +08:00
parent 965777323e
commit c8451cab52
65 changed files with 855 additions and 806 deletions
+11 -9
View File
@@ -5,7 +5,7 @@
#include "modules/bluetooth/bluetooth.h"
#include "util/stringUtils.h"
#define FF_BLUETOOTH_NUM_FORMAT_ARGS 4
#define FF_BLUETOOTH_NUM_FORMAT_ARGS 5
static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* device, uint8_t index)
{
@@ -33,10 +33,11 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de
ffPercentAppendNum(&percentageStr, device->battery, options->percent, false, &options->moduleArgs);
FF_PRINT_FORMAT_CHECKED(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BLUETOOTH_NUM_FORMAT_ARGS, ((FFformatarg[]) {
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->address},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->type},
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr}
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name, "name"},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->address, "address"},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->type, "type"},
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr, "battery-percentage"},
{FF_FORMAT_ARG_TYPE_BOOL, &device->connected, "connected"},
}));
}
}
@@ -174,10 +175,11 @@ void ffGenerateBluetoothJsonResult(FF_MAYBE_UNUSED FFBluetoothOptions* options,
void ffPrintBluetoothHelpFormat(void)
{
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BLUETOOTH_MODULE_NAME, "{1} ({4})", FF_BLUETOOTH_NUM_FORMAT_ARGS, ((const char* []) {
"Name",
"Address",
"Type",
"Battery percentage"
"Name - name",
"Address - address",
"Type - type",
"Battery percentage - battery-percentage",
"Is connected - connected",
}));
}