mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 09:58:03 +02:00
Global: refactor code of -h <module>-format
This commit is contained in:
+2
-4
@@ -42,7 +42,5 @@ typedef struct FFformatarg
|
||||
|
||||
void ffFormatAppendFormatArg(FFstrbuf* buffer, const FFformatarg* formatarg);
|
||||
void ffParseFormatString(FFstrbuf* buffer, const FFstrbuf* formatstr, uint32_t numArgs, const FFformatarg* arguments);
|
||||
#define FF_PARSE_FORMAT_STRING_CHECKED(buffer, formatstr, numArgs, arguments) do {\
|
||||
static_assert(sizeof(arguments) / sizeof(*arguments) == (numArgs), "Invalid number of format arguments");\
|
||||
ffParseFormatString((buffer), (formatstr), (numArgs), (arguments));\
|
||||
} while (0)
|
||||
#define FF_PARSE_FORMAT_STRING_CHECKED(buffer, formatstr, arguments) \
|
||||
ffParseFormatString((buffer), (formatstr), sizeof(arguments) / sizeof(*arguments), (arguments));
|
||||
|
||||
+15
-23
@@ -6,6 +6,20 @@ struct yyjson_val;
|
||||
struct yyjson_mut_doc;
|
||||
struct yyjson_mut_val;
|
||||
|
||||
typedef struct FFModuleFormatArg
|
||||
{
|
||||
const char* desc;
|
||||
const char* name;
|
||||
} FFModuleFormatArg;
|
||||
|
||||
typedef struct FFModuleFormatArgList
|
||||
{
|
||||
FFModuleFormatArg* args;
|
||||
uint32_t count;
|
||||
} FFModuleFormatArgList;
|
||||
|
||||
#define FF_FORMAT_ARG_LIST(list) { .args = list, .count = sizeof(list) / sizeof(FFModuleFormatArg) }
|
||||
|
||||
// Must be the first field of FFModuleOptions
|
||||
typedef struct FFModuleBaseInfo
|
||||
{
|
||||
@@ -19,32 +33,10 @@ typedef struct FFModuleBaseInfo
|
||||
void (*parseJsonObject)(void* options, struct yyjson_val *module);
|
||||
void (*printModule)(void* options);
|
||||
void (*generateJsonResult)(void* options, struct yyjson_mut_doc* doc, struct yyjson_mut_val* module);
|
||||
void (*printHelpFormat)(void);
|
||||
void (*generateJsonConfig)(void* options, struct yyjson_mut_doc* doc, struct yyjson_mut_val* obj);
|
||||
FFModuleFormatArgList formatArgs;
|
||||
} FFModuleBaseInfo;
|
||||
|
||||
static inline void ffOptionInitModuleBaseInfo(
|
||||
FFModuleBaseInfo* baseInfo,
|
||||
const char* name,
|
||||
const char* description,
|
||||
void* parseCommandOptions, // bool (*const parseCommandOptions)(void* options, const char* key, const char* value)
|
||||
void* parseJsonObject, // void (*const parseJsonObject)(void* options, yyjson_val *module)
|
||||
void* printModule, // void (*const printModule)(void* options)
|
||||
void* generateJsonResult, // void (*const generateJsonResult)(void* options, yyjson_mut_doc* doc, yyjson_mut_val* obj)
|
||||
void (*printHelpFormat)(void),
|
||||
void* generateJsonConfig // void (*const generateJsonConfig)(void* options, yyjson_mut_doc* doc, yyjson_mut_val* obj)
|
||||
)
|
||||
{
|
||||
baseInfo->name = name;
|
||||
baseInfo->description = description;
|
||||
baseInfo->parseCommandOptions = (__typeof__(baseInfo->parseCommandOptions)) parseCommandOptions;
|
||||
baseInfo->parseJsonObject = (__typeof__(baseInfo->parseJsonObject)) parseJsonObject;
|
||||
baseInfo->printModule = (__typeof__(baseInfo->printModule)) printModule;
|
||||
baseInfo->generateJsonResult = (__typeof__(baseInfo->generateJsonResult)) generateJsonResult;
|
||||
baseInfo->printHelpFormat = printHelpFormat;
|
||||
baseInfo->generateJsonConfig = (__typeof__(baseInfo->generateJsonConfig)) generateJsonConfig;
|
||||
}
|
||||
|
||||
typedef enum __attribute__((__packed__)) FFModuleKeyType
|
||||
{
|
||||
FF_MODULE_KEY_TYPE_NONE = 0,
|
||||
|
||||
+1
-16
@@ -50,7 +50,7 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
|
||||
else
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, 2, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &moduleArgs->key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(moduleIndex, "index"),
|
||||
FF_FORMAT_ARG(moduleArgs->keyIcon, "icon"),
|
||||
}));
|
||||
@@ -148,18 +148,3 @@ void ffPrintCharTimes(char c, uint32_t times)
|
||||
if(remaining > 0)
|
||||
fwrite(str, 1, remaining, stdout);
|
||||
}
|
||||
|
||||
void ffPrintModuleFormatHelp(const char* name, const char* def, uint32_t numArgs, const char* args[])
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreateS(name);
|
||||
ffStrbufLowerCase(&buffer);
|
||||
printf("--%s-format:\n", buffer.chars);
|
||||
printf("Sets the format string for %s output.\n", name);
|
||||
puts("To see how a format string is constructed, take a look at \"fastfetch --help format\".");
|
||||
puts("The following values are passed:");
|
||||
|
||||
for(unsigned i = 0; i < numArgs; i++)
|
||||
printf(" {%u}: %s\n", i + 1, args[i]);
|
||||
|
||||
printf("The default is something similar to \"%s\".\n", def);
|
||||
}
|
||||
|
||||
+2
-10
@@ -14,16 +14,8 @@ typedef enum __attribute__((__packed__)) FFPrintType {
|
||||
|
||||
void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType);
|
||||
void ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments);
|
||||
#define FF_PRINT_FORMAT_CHECKED(moduleName, moduleIndex, moduleArgs, printType, numArgs, arguments) do {\
|
||||
static_assert(sizeof(arguments) / sizeof(*arguments) == (numArgs), "Invalid number of format arguments");\
|
||||
ffPrintFormat((moduleName), (moduleIndex), (moduleArgs), (printType), (numArgs), (arguments));\
|
||||
} while (0)
|
||||
#define FF_PRINT_FORMAT_CHECKED(moduleName, moduleIndex, moduleArgs, printType, arguments) \
|
||||
ffPrintFormat((moduleName), (moduleIndex), (moduleArgs), (printType), (sizeof(arguments) / sizeof(*arguments)), (arguments));
|
||||
FF_C_PRINTF(5, 6) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...);
|
||||
void ffPrintColor(const FFstrbuf* colorValue);
|
||||
void ffPrintCharTimes(char c, uint32_t times);
|
||||
|
||||
void ffPrintModuleFormatHelp(const char* name, const char* def, uint32_t numArgs, const char* args[]);
|
||||
#define FF_PRINT_MODULE_FORMAT_HELP_CHECKED(moduleName, def, numArgs, args) do {\
|
||||
static_assert(sizeof(args) / sizeof(*args) == (numArgs), "Invalid number of format arguments");\
|
||||
ffPrintModuleFormatHelp((moduleName), (def), (numArgs), (args));\
|
||||
} while (0)
|
||||
|
||||
+15
-2
@@ -2,6 +2,7 @@
|
||||
#include "common/commandoption.h"
|
||||
#include "common/io/io.h"
|
||||
#include "common/jsonconfig.h"
|
||||
#include "common/printing.h"
|
||||
#include "detection/version/version.h"
|
||||
#include "util/stringUtils.h"
|
||||
#include "util/mallocHelper.h"
|
||||
@@ -18,13 +19,25 @@
|
||||
static void printCommandFormatHelp(const char* command)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY type = ffStrbufCreateNS((uint32_t) (strlen(command) - strlen("-format")), command);
|
||||
ffStrbufLowerCase(&type);
|
||||
for (FFModuleBaseInfo** modules = ffModuleInfos[toupper(command[0]) - 'A']; *modules; ++modules)
|
||||
{
|
||||
FFModuleBaseInfo* baseInfo = *modules;
|
||||
if (ffStrbufIgnCaseEqualS(&type, baseInfo->name))
|
||||
{
|
||||
if (baseInfo->printHelpFormat)
|
||||
baseInfo->printHelpFormat();
|
||||
if (baseInfo->formatArgs.count > 0)
|
||||
{
|
||||
printf("--%s-format:\n", type.chars);
|
||||
printf("Sets the format string for %s output.\n", baseInfo->name);
|
||||
puts("To see how a format string is constructed, take a look at \"fastfetch --help format\".");
|
||||
puts("The following values are passed:");
|
||||
|
||||
for (unsigned i = 0; i < baseInfo->formatArgs.count; i++)
|
||||
{
|
||||
const FFModuleFormatArg* arg = &baseInfo->formatArgs.args[i];
|
||||
printf("%16s {%u}: %s\n", arg->name, i + 1, arg->desc);
|
||||
}
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "Error: Module '%s' doesn't support output formatting\n", baseInfo->name);
|
||||
return;
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include "modules/battery/battery.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BATTERY_NUM_FORMAT_ARGS 14
|
||||
|
||||
static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uint8_t index)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate();
|
||||
@@ -22,7 +20,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
else
|
||||
{
|
||||
ffStrbufClear(&key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 2, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(result->modelName, "name"),
|
||||
}));
|
||||
@@ -105,7 +103,7 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
|
||||
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
|
||||
ffTempsAppendNum(result->temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BATTERY_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result->manufacturer, "manufacturer"),
|
||||
FF_FORMAT_ARG(result->modelName, "model-name"),
|
||||
FF_FORMAT_ARG(result->technology, "technology"),
|
||||
@@ -270,39 +268,35 @@ void ffGenerateBatteryJsonResult(FFBatteryOptions* options, yyjson_mut_doc* doc,
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintBatteryHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BATTERY_MODULE_NAME, "{4} ({12} hours {13} mins) [{5}]", FF_BATTERY_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Battery manufacturer - manufacturer",
|
||||
"Battery model name - model-name",
|
||||
"Battery technology - technology",
|
||||
"Battery capacity (percentage num) - capacity",
|
||||
"Battery status - status",
|
||||
"Battery temperature (formatted) - temperature",
|
||||
"Battery cycle count - cycle-count",
|
||||
"Battery serial number - serial",
|
||||
"Battery manufactor date - manufacture-date",
|
||||
"Battery capacity (percentage bar) - capacity-bar",
|
||||
"Battery time remaining days - time-days",
|
||||
"Battery time remaining hours - time-hours",
|
||||
"Battery time remaining minutes - time-minutes",
|
||||
"Battery time remaining seconds - time-seconds",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BATTERY_MODULE_NAME,
|
||||
.description = "Print battery capacity, status, etc",
|
||||
.parseCommandOptions = (void*) ffParseBatteryCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBatteryJsonObject,
|
||||
.printModule = (void*) ffPrintBattery,
|
||||
.generateJsonResult = (void*) ffGenerateBatteryJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBatteryJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Battery manufacturer", "manufacturer"},
|
||||
{"Battery model name", "model-name"},
|
||||
{"Battery technology", "technology"},
|
||||
{"Battery capacity (percentage num)", "capacity"},
|
||||
{"Battery status", "status"},
|
||||
{"Battery temperature (formatted)", "temperature"},
|
||||
{"Battery cycle count", "cycle-count"},
|
||||
{"Battery serial number", "serial"},
|
||||
{"Battery manufactor date", "manufacture-date"},
|
||||
{"Battery capacity (percentage bar)", "capacity-bar"},
|
||||
{"Battery time remaining days", "time-days"},
|
||||
{"Battery time remaining hours", "time-hours"},
|
||||
{"Battery time remaining minutes", "time-minutes"},
|
||||
{"Battery time remaining seconds", "time-seconds"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBatteryOptions(FFBatteryOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BATTERY_MODULE_NAME,
|
||||
"Print battery capacity, status, etc",
|
||||
ffParseBatteryCommandOptions,
|
||||
ffParseBatteryJsonObject,
|
||||
ffPrintBattery,
|
||||
ffGenerateBatteryJsonResult,
|
||||
ffPrintBatteryHelpFormat,
|
||||
ffGenerateBatteryJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->temp = false;
|
||||
options->tempConfig = (FFColorRangeConfig) { 60, 80 };
|
||||
|
||||
+19
-25
@@ -4,8 +4,6 @@
|
||||
#include "modules/bios/bios.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BIOS_NUM_FORMAT_ARGS 5
|
||||
|
||||
void ffPrintBios(FFBiosOptions* options)
|
||||
{
|
||||
FFBiosResult bios;
|
||||
@@ -43,7 +41,7 @@ void ffPrintBios(FFBiosOptions* options)
|
||||
else
|
||||
{
|
||||
ffStrbufClear(&key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 2, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(bios.type, "type"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
}));
|
||||
@@ -60,7 +58,7 @@ void ffPrintBios(FFBiosOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BIOS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(bios.date, "date"),
|
||||
FF_FORMAT_ARG(bios.release, "release"),
|
||||
FF_FORMAT_ARG(bios.vendor, "vendor"),
|
||||
@@ -144,30 +142,26 @@ exit:
|
||||
ffStrbufDestroy(&bios.type);
|
||||
}
|
||||
|
||||
void ffPrintBiosHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BIOS_MODULE_NAME, "{4} ({2})", FF_BIOS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"bios date - date",
|
||||
"bios release - release",
|
||||
"bios vendor - vendor",
|
||||
"bios version - version",
|
||||
"firmware type - type",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BIOS_MODULE_NAME,
|
||||
.description = "Print information of 1st-stage bootloader (name, version, release date, etc)",
|
||||
.parseCommandOptions = (void*) ffParseBiosCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBiosJsonObject,
|
||||
.printModule = (void*) ffPrintBios,
|
||||
.generateJsonResult = (void*) ffGenerateBiosJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBiosJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Bios date", "date"},
|
||||
{"Bios release", "release"},
|
||||
{"Bios vendor", "vendor"},
|
||||
{"Bios version", "version"},
|
||||
{"Firmware type", "type"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBiosOptions(FFBiosOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BIOS_MODULE_NAME,
|
||||
"Print information of 1st-stage bootloader (name, version, release date, etc)",
|
||||
ffParseBiosCommandOptions,
|
||||
ffParseBiosJsonObject,
|
||||
ffPrintBios,
|
||||
ffGenerateBiosJsonResult,
|
||||
ffPrintBiosHelpFormat,
|
||||
ffGenerateBiosJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "modules/bluetooth/bluetooth.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BLUETOOTH_NUM_FORMAT_ARGS 6
|
||||
|
||||
static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* device, uint8_t index)
|
||||
{
|
||||
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
|
||||
@@ -47,7 +45,7 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de
|
||||
if(percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&percentageBar, device->battery, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BLUETOOTH_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->name, "name"),
|
||||
FF_FORMAT_ARG(device->address, "address"),
|
||||
FF_FORMAT_ARG(device->type, "type"),
|
||||
@@ -188,31 +186,27 @@ 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 - device name",
|
||||
"Address - remote device address",
|
||||
"Type - type",
|
||||
"Battery percentage number - battery-percentage",
|
||||
"Is connected - connected",
|
||||
"Battery percentage bar - battery-percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BLUETOOTH_MODULE_NAME,
|
||||
.description = "List (connected) bluetooth devices",
|
||||
.parseCommandOptions = (void*) ffParseBluetoothCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBluetoothJsonObject,
|
||||
.printModule = (void*) ffPrintBluetooth,
|
||||
.generateJsonResult = (void*) ffGenerateBluetoothJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBluetoothJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name", "name"},
|
||||
{"Address", "address"},
|
||||
{"Type", "type"},
|
||||
{"Battery percentage number", "battery-percentage"},
|
||||
{"Is connected", "connected"},
|
||||
{"Battery percentage bar", "battery-percentage-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBluetoothOptions(FFBluetoothOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BLUETOOTH_MODULE_NAME,
|
||||
"List (connected) bluetooth devices",
|
||||
ffParseBluetoothCommandOptions,
|
||||
ffParseBluetoothJsonObject,
|
||||
ffPrintBluetooth,
|
||||
ffGenerateBluetoothJsonResult,
|
||||
ffPrintBluetoothHelpFormat,
|
||||
ffGenerateBluetoothJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->showDisconnected = false;
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 20, 0 };
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "modules/bluetoothradio/bluetoothradio.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BLUETOOTHRADIO_NUM_FORMAT_ARGS 8
|
||||
#define FF_BLUETOOTHRADIO_DISPLAY_NAME "Bluetooth Radio"
|
||||
|
||||
static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadioResult* radio, uint8_t index)
|
||||
@@ -17,7 +16,7 @@ static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadio
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(radio->name, "name"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -55,7 +54,7 @@ static void printDevice(FFBluetoothRadioOptions* options, const FFBluetoothRadio
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BLUETOOTHRADIO_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(radio->name, "name"),
|
||||
FF_FORMAT_ARG(radio->address, "address"),
|
||||
FF_FORMAT_ARG(radio->lmpVersion, "lmp-version"),
|
||||
@@ -181,33 +180,29 @@ void ffGenerateBluetoothRadioJsonResult(FF_MAYBE_UNUSED FFBluetoothRadioOptions*
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintBluetoothRadioHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BLUETOOTHRADIO_MODULE_NAME, "Bluetooth {5} ({6})", FF_BLUETOOTHRADIO_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Radio name for discovering - name",
|
||||
"Address - local radio address",
|
||||
"LMP version - lmp-version",
|
||||
"LMP subversion - lmp-subversion",
|
||||
"Bluetooth version - version",
|
||||
"Vendor - vendor",
|
||||
"Discoverable - discoverable",
|
||||
"Connectable / Pairable - connectable",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BLUETOOTHRADIO_MODULE_NAME,
|
||||
.description = "List bluetooth radios width supported version and vendor",
|
||||
.parseCommandOptions = (void*) ffParseBluetoothRadioCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBluetoothRadioJsonObject,
|
||||
.printModule = (void*) ffPrintBluetoothRadio,
|
||||
.generateJsonResult = (void*) ffGenerateBluetoothRadioJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBluetoothRadioJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Radio name for discovering", "name"},
|
||||
{"Address", "address"},
|
||||
{"LMP version", "lmp-version"},
|
||||
{"LMP subversion", "lmp-subversion"},
|
||||
{"Bluetooth version", "version"},
|
||||
{"Vendor", "vendor"},
|
||||
{"Discoverable", "discoverable"},
|
||||
{"Connectable / Pairable", "connectable"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBluetoothRadioOptions(FFBluetoothRadioOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BLUETOOTHRADIO_MODULE_NAME,
|
||||
"List bluetooth radios width supported version and vendor",
|
||||
ffParseBluetoothRadioCommandOptions,
|
||||
ffParseBluetoothRadioJsonObject,
|
||||
ffPrintBluetoothRadio,
|
||||
ffGenerateBluetoothRadioJsonResult,
|
||||
ffPrintBluetoothRadioHelpFormat,
|
||||
ffGenerateBluetoothRadioJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+17
-23
@@ -4,8 +4,6 @@
|
||||
#include "modules/board/board.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BOARD_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintBoard(FFBoardOptions* options)
|
||||
{
|
||||
FFBoardResult result;
|
||||
@@ -37,7 +35,7 @@ void ffPrintBoard(FFBoardOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BOARD_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BOARD_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.name, "name"),
|
||||
FF_FORMAT_ARG(result.vendor, "vendor"),
|
||||
FF_FORMAT_ARG(result.version, "version"),
|
||||
@@ -122,29 +120,25 @@ exit:
|
||||
ffStrbufDestroy(&board.serial);
|
||||
}
|
||||
|
||||
void ffPrintBoardHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BOARD_MODULE_NAME, "{1} ({3})", FF_BOARD_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"board name - name",
|
||||
"board vendor - vendor",
|
||||
"board version - version",
|
||||
"board serial number - serial",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BOARD_MODULE_NAME,
|
||||
.description = "Print motherboard name and other info",
|
||||
.parseCommandOptions = (void*) ffParseBoardCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBoardJsonObject,
|
||||
.printModule = (void*) ffPrintBoard,
|
||||
.generateJsonResult = (void*) ffGenerateBoardJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBoardJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Board name", "name"},
|
||||
{"Board vendor", "vendor"},
|
||||
{"Board version", "version"},
|
||||
{"Board serial number", "serial"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBoardOptions(FFBoardOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BOARD_MODULE_NAME,
|
||||
"Print motherboard name and other info",
|
||||
ffParseBoardCommandOptions,
|
||||
ffParseBoardJsonObject,
|
||||
ffPrintBoard,
|
||||
ffGenerateBoardJsonResult,
|
||||
ffPrintBoardHelpFormat,
|
||||
ffGenerateBoardJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "modules/bootmgr/bootmgr.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BOOTMGR_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintBootmgr(FFBootmgrOptions* options)
|
||||
{
|
||||
FFBootmgrResult bootmgr = {
|
||||
@@ -39,7 +37,7 @@ void ffPrintBootmgr(FFBootmgrOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BOOTMGR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BOOTMGR_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_BOOTMGR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(bootmgr.name, "name"),
|
||||
FF_FORMAT_ARG(bootmgr.firmware, "firmware-path"),
|
||||
FF_FORMAT_ARG(firmwareName, "firmware-name"),
|
||||
@@ -111,29 +109,25 @@ exit:
|
||||
ffStrbufDestroy(&bootmgr.firmware);
|
||||
}
|
||||
|
||||
void ffPrintBootmgrHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BOOTMGR_MODULE_NAME, "{4} ({2})", FF_BOOTMGR_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name / description - name",
|
||||
"Firmware file path - firmware-path",
|
||||
"Firmware file name - firmware-name",
|
||||
"Is secure boot enabled - secure-boot",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BOOTMGR_MODULE_NAME,
|
||||
.description = "Print information of 2nd-stage bootloader (name, firmware, etc)",
|
||||
.parseCommandOptions = (void*) ffParseBootmgrCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBootmgrJsonObject,
|
||||
.printModule = (void*) ffPrintBootmgr,
|
||||
.generateJsonResult = (void*) ffGenerateBootmgrJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBootmgrJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name / description", "name"},
|
||||
{"Firmware file path", "firmware-path"},
|
||||
{"Firmware file name", "firmware-name"},
|
||||
{"Is secure boot enabled", "secure-boot"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBootmgrOptions(FFBootmgrOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BOOTMGR_MODULE_NAME,
|
||||
"Print information of 2nd-stage bootloader (name, firmware, etc)",
|
||||
ffParseBootmgrCommandOptions,
|
||||
ffParseBootmgrJsonObject,
|
||||
ffPrintBootmgr,
|
||||
ffGenerateBootmgrJsonResult,
|
||||
ffPrintBootmgrHelpFormat,
|
||||
ffGenerateBootmgrJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -16,19 +16,17 @@ void ffParseBreakJsonObject(FF_MAYBE_UNUSED FFBreakOptions* options, FF_MAYBE_UN
|
||||
{
|
||||
}
|
||||
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BREAK_MODULE_NAME,
|
||||
.description = "Print a empty line",
|
||||
.parseCommandOptions = (void*) ffParseBreakCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBreakJsonObject,
|
||||
.printModule = (void*) ffPrintBreak,
|
||||
};
|
||||
|
||||
void ffInitBreakOptions(FF_MAYBE_UNUSED FFBreakOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BREAK_MODULE_NAME,
|
||||
"Print a empty line",
|
||||
ffParseBreakCommandOptions,
|
||||
ffParseBreakJsonObject,
|
||||
ffPrintBreak,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
}
|
||||
|
||||
void ffDestroyBreakOptions(FF_MAYBE_UNUSED FFBreakOptions* options)
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "modules/brightness/brightness.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BRIGHTNESS_NUM_FORMAT_ARGS 6
|
||||
|
||||
void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFBrightnessResult));
|
||||
@@ -57,7 +55,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
else
|
||||
{
|
||||
uint32_t moduleIndex = result.length == 1 ? 0 : index + 1;
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(moduleIndex, "index"),
|
||||
FF_FORMAT_ARG(item->name, "name"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -95,7 +93,7 @@ void ffPrintBrightness(FFBrightnessOptions* options)
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&valueBar, percent, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BRIGHTNESS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(valueNum, "percentage"),
|
||||
FF_FORMAT_ARG(item->name, "name"),
|
||||
FF_FORMAT_ARG(item->max, "max"),
|
||||
@@ -214,31 +212,27 @@ void ffGenerateBrightnessJsonResult(FF_MAYBE_UNUSED FFBrightnessOptions* options
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintBrightnessHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BRIGHTNESS_MODULE_NAME, "{1}", FF_BRIGHTNESS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Screen brightness (percentage num) - percentage",
|
||||
"Screen name - name",
|
||||
"Maximum brightness value - max",
|
||||
"Minimum brightness value - min",
|
||||
"Current brightness value - current",
|
||||
"Screen brightness (percentage bar) - percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BRIGHTNESS_MODULE_NAME,
|
||||
.description = "Print current brightness level of your monitors",
|
||||
.parseCommandOptions = (void*) ffParseBrightnessCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBrightnessJsonObject,
|
||||
.printModule = (void*) ffPrintBrightness,
|
||||
.generateJsonResult = (void*) ffGenerateBrightnessJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBrightnessJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Screen brightness (percentage num)", "percentage"},
|
||||
{"Screen name", "name"},
|
||||
{"Maximum brightness value", "max"},
|
||||
{"Minimum brightness value", "min"},
|
||||
{"Current brightness value", "current"},
|
||||
{"Screen brightness (percentage bar)", "percentage-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBrightnessOptions(FFBrightnessOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BRIGHTNESS_MODULE_NAME,
|
||||
"Print current brightness level of your monitors",
|
||||
ffParseBrightnessCommandOptions,
|
||||
ffParseBrightnessJsonObject,
|
||||
ffPrintBrightness,
|
||||
ffGenerateBrightnessJsonResult,
|
||||
ffPrintBrightnessHelpFormat,
|
||||
ffGenerateBrightnessJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->ddcciSleep = 10;
|
||||
|
||||
+27
-33
@@ -5,8 +5,6 @@
|
||||
#include "modules/btrfs/btrfs.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_BTRFS_NUM_FORMAT_ARGS 13
|
||||
|
||||
static void printBtrfs(FFBtrfsOptions* options, FFBtrfsResult* result, uint8_t index)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
@@ -20,7 +18,7 @@ static void printBtrfs(FFBtrfsOptions* options, FFBtrfsResult* result, uint8_t i
|
||||
else
|
||||
{
|
||||
ffStrbufClear(&buffer);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(result->name, "name"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -80,7 +78,7 @@ static void printBtrfs(FFBtrfsOptions* options, FFBtrfsResult* result, uint8_t i
|
||||
FF_STRBUF_AUTO_DESTROY sectorSizePretty = ffStrbufCreate();
|
||||
ffParseSize(result->sectorSize, §orSizePretty);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(buffer.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BTRFS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(buffer.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result->name, "name"),
|
||||
FF_FORMAT_ARG(result->uuid, "uuid"),
|
||||
FF_FORMAT_ARG(result->devices, "devices"),
|
||||
@@ -218,38 +216,34 @@ void ffGenerateBtrfsJsonResult(FF_MAYBE_UNUSED FFBtrfsOptions* options, yyjson_m
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintBtrfsHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BTRFS_MODULE_NAME, "{5} / {7} ({8}, {9} allocated)", FF_BTRFS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name / Label - name",
|
||||
"UUID - uuid",
|
||||
"Associated devices - devices",
|
||||
"Enabled features - features",
|
||||
"Size used - used",
|
||||
"Size allocated - allocated",
|
||||
"Size total - total",
|
||||
"Used percentage num - used-percentage",
|
||||
"Allocated percentage num - allocated-percentage",
|
||||
"Used percentage bar - used-percentage-bar",
|
||||
"Allocated percentage bar - allocated-percentage-bar",
|
||||
"Node size - node-size",
|
||||
"Sector size - sector-size",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_BTRFS_MODULE_NAME,
|
||||
.description = "Print BTRFS volumes",
|
||||
.parseCommandOptions = (void*) ffParseBtrfsCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseBtrfsJsonObject,
|
||||
.printModule = (void*) ffPrintBtrfs,
|
||||
.generateJsonResult = (void*) ffGenerateBtrfsJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateBtrfsJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name / Label", "name"},
|
||||
{"UUID", "uuid"},
|
||||
{"Associated devices", "devices"},
|
||||
{"Enabled features", "features"},
|
||||
{"Size used", "used"},
|
||||
{"Size allocated", "allocated"},
|
||||
{"Size total", "total"},
|
||||
{"Used percentage num", "used-percentage"},
|
||||
{"Allocated percentage num", "allocated-percentage"},
|
||||
{"Used percentage bar", "used-percentage-bar"},
|
||||
{"Allocated percentage bar", "allocated-percentage-bar"},
|
||||
{"Node size", "node-size"},
|
||||
{"Sector size", "sector-size"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitBtrfsOptions(FFBtrfsOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_BTRFS_MODULE_NAME,
|
||||
"Print BTRFS volumes",
|
||||
ffParseBtrfsCommandOptions,
|
||||
ffParseBtrfsJsonObject,
|
||||
ffPrintBtrfs,
|
||||
ffGenerateBtrfsJsonResult,
|
||||
ffPrintBtrfsHelpFormat,
|
||||
ffGenerateBtrfsJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 80, 0 };
|
||||
}
|
||||
|
||||
+19
-25
@@ -5,8 +5,6 @@
|
||||
#include "modules/camera/camera.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CAMERA_NUM_FORMAT_ARGS 6
|
||||
|
||||
static void printDevice(FFCameraOptions* options, const FFCameraResult* device, uint8_t index)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
@@ -27,7 +25,7 @@ static void printDevice(FFCameraOptions* options, const FFCameraResult* device,
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CAMERA_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CAMERA_NUM_FORMAT_ARGS, (((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CAMERA_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, (((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->name, "name"),
|
||||
FF_FORMAT_ARG(device->vendor, "vendor"),
|
||||
FF_FORMAT_ARG(device->colorspace, "colorspace"),
|
||||
@@ -136,31 +134,27 @@ void ffGenerateCameraJsonResult(FF_MAYBE_UNUSED FFCameraOptions* options, yyjson
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintCameraHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CAMERA_MODULE_NAME, "{1} ({4}px x {5}px)", FF_CAMERA_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Device name - name",
|
||||
"Vendor - vendor",
|
||||
"Color space - colorspace",
|
||||
"Identifier - id",
|
||||
"Width (in px) - width",
|
||||
"Height (in px) - height",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CAMERA_MODULE_NAME,
|
||||
.description = "Print available cameras",
|
||||
.parseCommandOptions = (void*) ffParseCameraCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCameraJsonObject,
|
||||
.printModule = (void*) ffPrintCamera,
|
||||
.generateJsonResult = (void*) ffGenerateCameraJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateCameraJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Device name", "name"},
|
||||
{"Vendor", "vendor"},
|
||||
{"Color space", "colorspace"},
|
||||
{"Identifier", "id"},
|
||||
{"Width (in px)", "width"},
|
||||
{"Height (in px)", "height"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitCameraOptions(FFCameraOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CAMERA_MODULE_NAME,
|
||||
"Print available cameras",
|
||||
ffParseCameraCommandOptions,
|
||||
ffParseCameraJsonObject,
|
||||
ffPrintCamera,
|
||||
ffGenerateCameraJsonResult,
|
||||
ffPrintCameraHelpFormat,
|
||||
ffGenerateCameraJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "modules/chassis/chassis.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CHASSIS_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintChassis(FFChassisOptions* options)
|
||||
{
|
||||
FFChassisResult result;
|
||||
@@ -38,7 +36,7 @@ void ffPrintChassis(FFChassisOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CHASSIS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.type, "type"),
|
||||
FF_FORMAT_ARG(result.vendor, "vendor"),
|
||||
FF_FORMAT_ARG(result.version, "version"),
|
||||
@@ -123,29 +121,25 @@ exit:
|
||||
ffStrbufDestroy(&result.serial);
|
||||
}
|
||||
|
||||
void ffPrintChassisHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CHASSIS_MODULE_NAME, "{1}", FF_CHASSIS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"chassis type - type",
|
||||
"chassis vendor - vendor",
|
||||
"chassis version - version",
|
||||
"chassis serial number - serial",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CHASSIS_MODULE_NAME,
|
||||
.description = "Print chassis type (desktop, laptop, etc)",
|
||||
.parseCommandOptions = (void*) ffParseChassisCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseChassisJsonObject,
|
||||
.printModule = (void*) ffPrintChassis,
|
||||
.generateJsonResult = (void*) ffGenerateChassisJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateChassisJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Chassis type", "type"},
|
||||
{"Chassis vendor", "vendor"},
|
||||
{"Chassis version", "version"},
|
||||
{"Chassis serial number", "serial"},
|
||||
})),
|
||||
};
|
||||
|
||||
void ffInitChassisOptions(FFChassisOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CHASSIS_MODULE_NAME,
|
||||
"Print chassis type (desktop, laptop, etc)",
|
||||
ffParseChassisCommandOptions,
|
||||
ffParseChassisJsonObject,
|
||||
ffPrintChassis,
|
||||
ffGenerateChassisJsonResult,
|
||||
ffPrintChassisHelpFormat,
|
||||
ffGenerateChassisJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+10
-11
@@ -291,19 +291,18 @@ void ffGenerateColorsJsonConfig(FFColorsOptions* options, yyjson_mut_doc* doc, y
|
||||
}
|
||||
}
|
||||
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_COLORS_MODULE_NAME,
|
||||
.description = "Print some colored blocks",
|
||||
.parseCommandOptions = (void*) ffParseColorsCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseColorsJsonObject,
|
||||
.printModule = (void*) ffPrintColors,
|
||||
.generateJsonConfig = (void*) ffGenerateColorsJsonConfig,
|
||||
};
|
||||
|
||||
void ffInitColorsOptions(FFColorsOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_COLORS_MODULE_NAME,
|
||||
"Print some colored blocks",
|
||||
ffParseColorsCommandOptions,
|
||||
ffParseColorsJsonObject,
|
||||
ffPrintColors,
|
||||
NULL,
|
||||
NULL,
|
||||
ffGenerateColorsJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
ffStrbufSetStatic(&options->moduleArgs.key, " ");
|
||||
options->symbol = FF_COLORS_SYMBOL_BACKGROUND;
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "modules/command/command.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_COMMAND_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintCommand(FFCommandOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate();
|
||||
@@ -39,7 +37,7 @@ void ffPrintCommand(FFCommandOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_COMMAND_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_COMMAND_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result, "result")
|
||||
}));
|
||||
}
|
||||
@@ -154,26 +152,22 @@ void ffGenerateCommandJsonResult(FF_MAYBE_UNUSED FFCommandOptions* options, yyjs
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "result", &result);
|
||||
}
|
||||
|
||||
void ffPrintCommandHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_COMMAND_MODULE_NAME, "{1}", FF_COMMAND_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Command result - result"
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_COMMAND_MODULE_NAME,
|
||||
.description = "Run custom shell scripts",
|
||||
.parseCommandOptions = (void*) ffParseCommandCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCommandJsonObject,
|
||||
.printModule = (void*) ffPrintCommand,
|
||||
.generateJsonResult = (void*) ffGenerateCommandJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateCommandJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Command result", "result"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitCommandOptions(FFCommandOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_COMMAND_MODULE_NAME,
|
||||
"Running custom shell scripts",
|
||||
ffParseCommandCommandOptions,
|
||||
ffParseCommandJsonObject,
|
||||
ffPrintCommand,
|
||||
ffGenerateCommandJsonResult,
|
||||
ffPrintCommandHelpFormat,
|
||||
ffGenerateCommandJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffStrbufInitStatic(&options->shell,
|
||||
|
||||
+23
-29
@@ -6,8 +6,6 @@
|
||||
#include "modules/cpu/cpu.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CPU_NUM_FORMAT_ARGS 10
|
||||
|
||||
static int sortCores(const FFCPUCore* a, const FFCPUCore* b)
|
||||
{
|
||||
return (int)b->freq - (int)a->freq;
|
||||
@@ -104,7 +102,7 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
|
||||
ffTempsAppendNum(cpu.temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPU_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(cpu.name, "name"),
|
||||
FF_FORMAT_ARG(cpu.vendor, "vendor"),
|
||||
FF_FORMAT_ARG(cpu.coresPhysical, "cores-physical"),
|
||||
@@ -241,35 +239,31 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
ffStrbufDestroy(&cpu.vendor);
|
||||
}
|
||||
|
||||
void ffPrintCPUHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPU_MODULE_NAME, "{1} ({5}) @ {7} GHz", FF_CPU_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name - name",
|
||||
"Vendor - vendor",
|
||||
"Physical core count - cores-physical",
|
||||
"Logical core count - cores-logical",
|
||||
"Online core count - cores-online",
|
||||
"Base frequency (formatted) - freq-base",
|
||||
"Max frequency (formatted) - freq-max",
|
||||
"Temperature (formatted) - temperature",
|
||||
"Logical core count grouped by frequency - core-types",
|
||||
"Processor package count - packages",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CPU_MODULE_NAME,
|
||||
.description = "Print CPU name, frequency, etc",
|
||||
.parseCommandOptions = (void*) ffParseCPUCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCPUJsonObject,
|
||||
.printModule = (void*) ffPrintCPU,
|
||||
.generateJsonResult = (void*) ffGenerateCPUJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateCPUJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name", "name"},
|
||||
{"Vendor", "vendor"},
|
||||
{"Physical core count", "cores-physical"},
|
||||
{"Logical core count", "cores-logical"},
|
||||
{"Online core count", "cores-online"},
|
||||
{"Base frequency (formatted)", "freq-base"},
|
||||
{"Max frequency (formatted)", "freq-max"},
|
||||
{"Temperature (formatted)", "temperature"},
|
||||
{"Logical core count grouped by frequency", "core-types"},
|
||||
{"Processor package count", "packages"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitCPUOptions(FFCPUOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CPU_MODULE_NAME,
|
||||
"Print CPU name, frequency, etc",
|
||||
ffParseCPUCommandOptions,
|
||||
ffParseCPUJsonObject,
|
||||
ffPrintCPU,
|
||||
ffGenerateCPUJsonResult,
|
||||
ffPrintCPUHelpFormat,
|
||||
ffGenerateCPUJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->temp = false;
|
||||
options->tempConfig = (FFColorRangeConfig) { 60, 80 };
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CPUCACHE_DISPLAY_NAME "CPU Cache"
|
||||
#define FF_CPUCACHE_NUM_FORMAT_ARGS 2
|
||||
|
||||
static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOptions* options)
|
||||
{
|
||||
@@ -22,7 +21,7 @@ static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOption
|
||||
else
|
||||
{
|
||||
uint32_t index = i + 1;
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(levelStr, "level"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -61,7 +60,7 @@ static void printCPUCacheNormal(const FFCPUCacheResult* result, FFCPUCacheOption
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate();
|
||||
ffParseSize(sum, &buffer2);
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_CPUCACHE_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(buffer, "result"),
|
||||
FF_FORMAT_ARG(buffer2, "sum"),
|
||||
}));
|
||||
@@ -94,7 +93,7 @@ static void printCPUCacheCompact(const FFCPUCacheResult* result, FFCPUCacheOptio
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY buffer2 = ffStrbufCreate();
|
||||
ffParseSize(sum, &buffer2);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUCACHE_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPUCACHE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(buffer, "result"),
|
||||
FF_FORMAT_ARG(buffer2, "sum"),
|
||||
}));
|
||||
@@ -228,27 +227,23 @@ exit:
|
||||
ffListDestroy(&result.caches[3]);
|
||||
}
|
||||
|
||||
void ffPrintCPUCacheHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPUCACHE_DISPLAY_NAME, "{1}", FF_CPUCACHE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Separate result - result",
|
||||
"Sum result - sum",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CPUCACHE_MODULE_NAME,
|
||||
.description = "Print CPU cache sizes",
|
||||
.parseCommandOptions = (void*) ffParseCPUCacheCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCPUCacheJsonObject,
|
||||
.printModule = (void*) ffPrintCPUCache,
|
||||
.generateJsonResult = (void*) ffGenerateCPUCacheJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateCPUCacheJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Separate result", "result"},
|
||||
{"Sum result", "sum"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitCPUCacheOptions(FFCPUCacheOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CPUCACHE_MODULE_NAME,
|
||||
"Print CPU cache sizes",
|
||||
ffParseCPUCacheCommandOptions,
|
||||
ffParseCPUCacheJsonObject,
|
||||
ffPrintCPUCache,
|
||||
ffGenerateCPUCacheJsonResult,
|
||||
ffPrintCPUCacheHelpFormat,
|
||||
ffGenerateCPUCacheJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->compact = false;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CPUUSAGE_DISPLAY_NAME "CPU Usage"
|
||||
#define FF_CPUUSAGE_NUM_FORMAT_ARGS 8
|
||||
|
||||
void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
{
|
||||
@@ -94,7 +93,7 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&maxBar, maxValue, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUUSAGE_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(avgNum, "avg"),
|
||||
FF_FORMAT_ARG(maxNum, "max"),
|
||||
FF_FORMAT_ARG(maxIndex, "max-index"),
|
||||
@@ -194,33 +193,29 @@ void ffGenerateCPUUsageJsonResult(FFCPUUsageOptions* options, yyjson_mut_doc* do
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintCPUUsageHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPUUSAGE_MODULE_NAME, "{1}", FF_CPUUSAGE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"CPU usage (percentage num, average) - avg",
|
||||
"CPU usage (percentage num, maximum) - max",
|
||||
"CPU core index of maximum usage - max-index",
|
||||
"CPU usage (percentage num, minimum) - min",
|
||||
"CPU core index of minimum usage - min-index",
|
||||
"CPU usage (percentage bar, average) - avg-bar",
|
||||
"CPU usage (percentage bar, maximum) - max-bar",
|
||||
"CPU usage (percentage bar, minimum) - min-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CPUUSAGE_MODULE_NAME,
|
||||
.description = "Print CPU usage. Costs some time to collect data",
|
||||
.parseCommandOptions = (void*) ffParseCPUUsageCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCPUUsageJsonObject,
|
||||
.printModule = (void*) ffPrintCPUUsage,
|
||||
.generateJsonResult = (void*) ffGenerateCPUUsageJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateCPUUsageJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"CPU usage (percentage num, average)", "avg"},
|
||||
{"CPU usage (percentage num, maximum)", "max"},
|
||||
{"CPU core index of maximum usage", "max-index"},
|
||||
{"CPU usage (percentage num, minimum)", "min"},
|
||||
{"CPU core index of minimum usage", "min-index"},
|
||||
{"CPU usage (percentage bar, average)", "avg-bar"},
|
||||
{"CPU usage (percentage bar, maximum)", "max-bar"},
|
||||
{"CPU usage (percentage bar, minimum)", "min-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitCPUUsageOptions(FFCPUUsageOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CPUUSAGE_MODULE_NAME,
|
||||
"Print CPU usage. Costs some time to collect data",
|
||||
ffParseCPUUsageCommandOptions,
|
||||
ffParseCPUUsageJsonObject,
|
||||
ffPrintCPUUsage,
|
||||
ffGenerateCPUUsageJsonResult,
|
||||
ffPrintCPUUsageHelpFormat,
|
||||
ffGenerateCPUUsageJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->separate = false;
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 80, 0 };
|
||||
|
||||
+15
-21
@@ -4,8 +4,6 @@
|
||||
#include "modules/cursor/cursor.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CURSOR_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintCursor(FFCursorOptions* options)
|
||||
{
|
||||
FFCursorResult result;
|
||||
@@ -38,7 +36,7 @@ void ffPrintCursor(FFCursorOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CURSOR_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_CURSOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.theme, "theme"),
|
||||
FF_FORMAT_ARG(result.size, "size"),
|
||||
}));
|
||||
@@ -110,27 +108,23 @@ void ffGenerateCursorJsonResult(FF_MAYBE_UNUSED FFCursorOptions* options, yyjson
|
||||
ffStrbufDestroy(&result.size);
|
||||
}
|
||||
|
||||
void ffPrintCursorHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CURSOR_MODULE_NAME, "{1} ({2}px)", FF_CURSOR_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Cursor theme - theme",
|
||||
"Cursor size - size"
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CURSOR_MODULE_NAME,
|
||||
.description = "Print cursor style name",
|
||||
.parseCommandOptions = (void*) ffParseCursorCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCursorJsonObject,
|
||||
.printModule = (void*) ffPrintCursor,
|
||||
.generateJsonResult = (void*) ffGenerateCursorJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateCursorJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Cursor theme", "theme"},
|
||||
{"Cursor size", "size"},
|
||||
})),
|
||||
};
|
||||
|
||||
void ffInitCursorOptions(FFCursorOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CURSOR_MODULE_NAME,
|
||||
"Print cursor style name",
|
||||
ffParseCursorCommandOptions,
|
||||
ffParseCursorJsonObject,
|
||||
ffPrintCursor,
|
||||
ffGenerateCursorJsonResult,
|
||||
ffPrintCursorHelpFormat,
|
||||
ffGenerateCursorJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+10
-11
@@ -44,19 +44,18 @@ void ffParseCustomJsonObject(FFCustomOptions* options, yyjson_val* module)
|
||||
}
|
||||
}
|
||||
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_CUSTOM_MODULE_NAME,
|
||||
.description = "Print a custom string, with or without key",
|
||||
.parseCommandOptions = (void*) ffParseCustomCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseCustomJsonObject,
|
||||
.printModule = (void*) ffPrintCustom,
|
||||
.generateJsonConfig = (void*) ffGenerateCustomJsonConfig,
|
||||
};
|
||||
|
||||
void ffInitCustomOptions(FFCustomOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_CUSTOM_MODULE_NAME,
|
||||
"Print a custom string, with or without key",
|
||||
ffParseCustomCommandOptions,
|
||||
ffParseCustomJsonObject,
|
||||
ffPrintCustom,
|
||||
NULL,
|
||||
NULL,
|
||||
ffGenerateCustomJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
ffStrbufSetStatic(&options->moduleArgs.key, " ");
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#pragma GCC diagnostic ignored "-Wformat" // warning: unknown conversion type character 'F' in format
|
||||
|
||||
#define FF_DATETIME_DISPLAY_NAME "Date & Time"
|
||||
#define FF_DATETIME_NUM_FORMAT_ARGS 23
|
||||
|
||||
typedef struct FFDateTimeResult
|
||||
{
|
||||
@@ -67,7 +66,7 @@ void ffPrintDateTimeFormat(struct tm* tm, const FFModuleArgs* moduleArgs)
|
||||
strftime(result.offsetFromUtc, sizeof(result.offsetFromUtc), "%z", tm);
|
||||
strftime(result.timezoneName, sizeof(result.timezoneName), "%Z", tm);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DATETIME_DISPLAY_NAME, 0, moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_DATETIME_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DATETIME_DISPLAY_NAME, 0, moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.year, "year"), // 1
|
||||
FF_FORMAT_ARG(result.yearShort, "year-short"), // 2
|
||||
FF_FORMAT_ARG(result.month, "month"), // 3
|
||||
@@ -158,48 +157,44 @@ void ffGenerateDateTimeJsonResult(FF_MAYBE_UNUSED FFDateTimeOptions* options, yy
|
||||
yyjson_mut_obj_add_strcpy(doc, module, "result", ffTimeToFullStr(ffTimeGetNow()));
|
||||
}
|
||||
|
||||
void ffPrintDateTimeHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DATETIME_MODULE_NAME, "{1}-{4}-{23} {14}:{18}:{20}", FF_DATETIME_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"year - year",
|
||||
"last two digits of year - year-short",
|
||||
"month - month",
|
||||
"month with leading zero - month-pretty",
|
||||
"month name - month-name",
|
||||
"month name short - month-name-short",
|
||||
"week number on year - week",
|
||||
"weekday - weekday",
|
||||
"weekday short - weekday-short",
|
||||
"day in year - day-in-year",
|
||||
"day in month - day-in-month",
|
||||
"day in week - day-in-week",
|
||||
"hour - hour",
|
||||
"hour with leading zero - hour-pretty",
|
||||
"hour 12h format - hour-12",
|
||||
"hour 12h format with leading zero - hour-12-pretty",
|
||||
"minute - minute",
|
||||
"minute with leading zero - minute-pretty",
|
||||
"second - second",
|
||||
"second with leading zero - second-pretty",
|
||||
"offset from UTC in the ISO 8601 format - offset-from-utc",
|
||||
"locale-dependent timezone name or abbreviation - timezone-name",
|
||||
"day in month with leading zero - day-pretty",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_DATETIME_MODULE_NAME,
|
||||
.description = "Print current date and time",
|
||||
.parseCommandOptions = (void*) ffParseDateTimeCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseDateTimeJsonObject,
|
||||
.printModule = (void*) ffPrintDateTime,
|
||||
.generateJsonResult = (void*) ffGenerateDateTimeJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateDateTimeJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Year", "year"},
|
||||
{"Last two digits of year", "year-short"},
|
||||
{"Month", "month"},
|
||||
{"Month with leading zero", "month-pretty"},
|
||||
{"Month name", "month-name"},
|
||||
{"Month name short", "month-name-short"},
|
||||
{"Week number on year", "week"},
|
||||
{"Weekday", "weekday"},
|
||||
{"Weekday short", "weekday-short"},
|
||||
{"Day in year", "day-in-year"},
|
||||
{"Day in month", "day-in-month"},
|
||||
{"Day in week", "day-in-week"},
|
||||
{"Hour", "hour"},
|
||||
{"Hour with leading zero", "hour-pretty"},
|
||||
{"Hour 12h format", "hour-12"},
|
||||
{"Hour 12h format with leading zero", "hour-12-pretty"},
|
||||
{"Minute", "minute"},
|
||||
{"Minute with leading zero", "minute-pretty"},
|
||||
{"Second", "second"},
|
||||
{"Second with leading zero", "second-pretty"},
|
||||
{"Offset from UTC in the ISO 8601 format", "offset-from-utc"},
|
||||
{"Locale-dependent timezone name or abbreviation", "timezone-name"},
|
||||
{"Day in month with leading zero", "day-pretty"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitDateTimeOptions(FFDateTimeOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_DATETIME_MODULE_NAME,
|
||||
"Print current date and time",
|
||||
ffParseDateTimeCommandOptions,
|
||||
ffParseDateTimeJsonObject,
|
||||
ffPrintDateTime,
|
||||
ffGenerateDateTimeJsonResult,
|
||||
ffPrintDateTimeHelpFormat,
|
||||
ffGenerateDateTimeJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+16
-22
@@ -5,8 +5,6 @@
|
||||
#include "modules/de/de.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_DE_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintDE(FFDEOptions* options)
|
||||
{
|
||||
const FFDisplayServerResult* result = ffConnectDisplayServer();
|
||||
@@ -36,7 +34,7 @@ void ffPrintDE(FFDEOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_DE_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result->deProcessName, "process-name"),
|
||||
FF_FORMAT_ARG(result->dePrettyName, "pretty-name"),
|
||||
FF_FORMAT_ARG(version, "version")
|
||||
@@ -113,28 +111,24 @@ void ffGenerateDEJsonResult(FF_MAYBE_UNUSED FFDEOptions* options, yyjson_mut_doc
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "version", &version);
|
||||
}
|
||||
|
||||
void ffPrintDEHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DE_MODULE_NAME, "{2} {3}", FF_DE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"DE process name - process-name",
|
||||
"DE pretty name - pretty-name",
|
||||
"DE version - version"
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_DE_MODULE_NAME,
|
||||
.description = "Print desktop environment name",
|
||||
.parseCommandOptions = (void*) ffParseDECommandOptions,
|
||||
.parseJsonObject = (void*) ffParseDEJsonObject,
|
||||
.printModule = (void*) ffPrintDE,
|
||||
.generateJsonResult = (void*) ffGenerateDEJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateDEJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"DE process name", "process-name"},
|
||||
{"DE pretty name", "pretty-name"},
|
||||
{"DE version", "version"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitDEOptions(FFDEOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_DE_MODULE_NAME,
|
||||
"Print desktop environment name",
|
||||
ffParseDECommandOptions,
|
||||
ffParseDEJsonObject,
|
||||
ffPrintDE,
|
||||
ffGenerateDEJsonResult,
|
||||
ffPrintDEHelpFormat,
|
||||
ffGenerateDEJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->slowVersionDetection = false;
|
||||
|
||||
+29
-33
@@ -7,7 +7,6 @@
|
||||
#include "modules/disk/disk.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_DISK_NUM_FORMAT_ARGS 14
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
|
||||
static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index)
|
||||
@@ -35,7 +34,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 5, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(disk->mountpoint, "mountpoint"),
|
||||
FF_FORMAT_ARG(disk->name, "name"),
|
||||
FF_FORMAT_ARG(disk->mountFrom, "mount-from"),
|
||||
@@ -126,7 +125,7 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk, uint32_t index
|
||||
bool isHidden = !!(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT);
|
||||
bool isReadOnly = !!(disk->type & FF_DISK_VOLUME_TYPE_READONLY_BIT);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISK_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(usedPretty, "size-used"),
|
||||
FF_FORMAT_ARG(totalPretty, "size-total"),
|
||||
FF_FORMAT_ARG(bytesPercentageNum, "size-percentage"),
|
||||
@@ -440,39 +439,36 @@ void ffGenerateDiskJsonResult(FFDiskOptions* options, yyjson_mut_doc* doc, yyjso
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintDiskHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISK_MODULE_NAME, "{1} / {2} ({3}) - {9}", FF_DISK_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Size used - size-used",
|
||||
"Size total - size-total",
|
||||
"Size percentage num - size-percentage",
|
||||
"Files used - files-used",
|
||||
"Files total - files-total",
|
||||
"Files percentage num - files-percentage",
|
||||
"True if external volume - is-external",
|
||||
"True if hidden volume - is-hidden",
|
||||
"Filesystem - filesystem",
|
||||
"Label / name - name",
|
||||
"True if read-only - is-readonly",
|
||||
"Create time in local timezone - create-time",
|
||||
"Size percentage bar - size-percentage-bar",
|
||||
"Files percentage bar - files-percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_DISK_MODULE_NAME,
|
||||
.description = "Print partitions, space usage, file system, etc",
|
||||
.parseCommandOptions = (void*) ffParseDiskCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseDiskJsonObject,
|
||||
.printModule = (void*) ffPrintDisk,
|
||||
.generateJsonResult = (void*) ffGenerateDiskJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateDiskJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Size used", "size-used"},
|
||||
{"Size total", "size-total"},
|
||||
{"Size percentage num", "size-percentage"},
|
||||
{"Files used", "files-used"},
|
||||
{"Files total", "files-total"},
|
||||
{"Files percentage num", "files-percentage"},
|
||||
{"True if external volume", "is-external"},
|
||||
{"True if hidden volume", "is-hidden"},
|
||||
{"Filesystem", "filesystem"},
|
||||
{"Label / name", "name"},
|
||||
{"True if read-only", "is-readonly"},
|
||||
{"Create time in local timezone", "create-time"},
|
||||
{"Size percentage bar", "size-percentage-bar"},
|
||||
{"Files percentage bar", "files-percentage-bar"},
|
||||
{},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitDiskOptions(FFDiskOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_DISK_MODULE_NAME,
|
||||
"Print partitions, space usage, file system, etc",
|
||||
ffParseDiskCommandOptions,
|
||||
ffParseDiskJsonObject,
|
||||
ffPrintDisk,
|
||||
ffGenerateDiskJsonResult,
|
||||
ffPrintDiskHelpFormat,
|
||||
ffGenerateDiskJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffStrbufInit(&options->folders);
|
||||
|
||||
+22
-27
@@ -6,7 +6,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_DISKIO_DISPLAY_NAME "Disk IO"
|
||||
#define FF_DISKIO_NUM_FORMAT_ARGS 8
|
||||
|
||||
static int sortDevices(const FFDiskIOResult* left, const FFDiskIOResult* right)
|
||||
{
|
||||
@@ -22,7 +21,7 @@ static void formatKey(const FFDiskIOOptions* options, FFDiskIOResult* dev, uint3
|
||||
else
|
||||
{
|
||||
ffStrbufClear(key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 4, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(dev->name, "name"),
|
||||
FF_FORMAT_ARG(dev->devPath, "dev-path"),
|
||||
@@ -75,7 +74,7 @@ void ffPrintDiskIO(FFDiskIOOptions* options)
|
||||
ffParseSize(dev->bytesWritten, &buffer2);
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer, "/s");
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISKIO_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(buffer, "size-read"),
|
||||
FF_FORMAT_ARG(buffer2, "size-written"),
|
||||
FF_FORMAT_ARG(dev->name, "name"),
|
||||
@@ -203,33 +202,29 @@ void ffGenerateDiskIOJsonResult(FFDiskIOOptions* options, yyjson_mut_doc* doc, y
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintDiskIOHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISKIO_MODULE_NAME, "{1} (R) - {2} (W)", FF_DISKIO_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Size of data read [per second] (formatted) - size-read",
|
||||
"Size of data written [per second] (formatted) - size-written",
|
||||
"Device name - name",
|
||||
"Device raw file path - dev-path",
|
||||
"Size of data read [per second] (in bytes) - bytes-read",
|
||||
"Size of data written [per second] (in bytes) - bytes-written",
|
||||
"Number of reads - read-count",
|
||||
"Number of writes - write-count",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_DISKIO_MODULE_NAME,
|
||||
.description = "Print physical disk I/O throughput",
|
||||
.parseCommandOptions = (void*) ffParseDiskIOCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseDiskIOJsonObject,
|
||||
.printModule = (void*) ffPrintDiskIO,
|
||||
.generateJsonResult = (void*) ffGenerateDiskIOJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateDiskIOJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Size of data read [per second] (formatted)", "size-read"},
|
||||
{"Size of data written [per second] (formatted)", "size-written"},
|
||||
{"Device name", "name"},
|
||||
{"Device raw file path", "dev-path"},
|
||||
{"Size of data read [per second] (in bytes)", "bytes-read"},
|
||||
{"Size of data written [per second] (in bytes)", "bytes-written"},
|
||||
{"Number of reads", "read-count"},
|
||||
{"Number of writes", "write-count"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitDiskIOOptions(FFDiskIOOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_DISKIO_MODULE_NAME,
|
||||
"Print physical disk I/O throughput",
|
||||
ffParseDiskIOCommandOptions,
|
||||
ffParseDiskIOJsonObject,
|
||||
ffPrintDiskIO,
|
||||
ffGenerateDiskIOJsonResult,
|
||||
ffPrintDiskIOHelpFormat,
|
||||
ffGenerateDiskIOJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffStrbufInit(&options->namePrefix);
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define FF_DISPLAY_NUM_FORMAT_ARGS 24
|
||||
|
||||
static int sortByNameAsc(FFDisplayResult* a, FFDisplayResult* b)
|
||||
{
|
||||
return ffStrbufComp(&a->name, &b->name);
|
||||
@@ -91,7 +89,7 @@ void ffPrintDisplay(FFDisplayOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 4, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(moduleIndex, "index"),
|
||||
FF_FORMAT_ARG(result->name, "name"),
|
||||
FF_FORMAT_ARG(displayType, "type"),
|
||||
@@ -186,7 +184,7 @@ void ffPrintDisplay(FFDisplayOptions* options)
|
||||
|
||||
double scaleFactor = (double) result->width / (double) result->scaledWidth;
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISPLAY_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result->width, "width"),
|
||||
FF_FORMAT_ARG(result->height, "height"),
|
||||
FF_FORMAT_ARG(refreshRate, "refresh-rate"),
|
||||
@@ -435,49 +433,45 @@ void ffGenerateDisplayJsonResult(FF_MAYBE_UNUSED FFDisplayOptions* options, yyjs
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintDisplayHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISPLAY_MODULE_NAME, "{1}x{2} @ {3}Hz (as {4}x{5}) [{7}]", FF_DISPLAY_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Screen configured width (in pixels) - width",
|
||||
"Screen configured height (in pixels) - height",
|
||||
"Screen configured refresh rate (in Hz) - refresh-rate",
|
||||
"Screen scaled width (in pixels) - scaled-width",
|
||||
"Screen scaled height (in pixels) - scaled-height",
|
||||
"Screen name - name",
|
||||
"Screen type (builtin, external or unknown) - type",
|
||||
"Screen rotation (in degrees) - rotation",
|
||||
"True if being the primary screen - is-primary",
|
||||
"Screen physical width (in millimeters) - physical-width",
|
||||
"Screen physical height (in millimeters) - physical-height",
|
||||
"Physical diagonal length in inches - inch",
|
||||
"Pixels per inch (PPI) - ppi",
|
||||
"Bits per color channel - bit-depth",
|
||||
"True if high dynamic range (HDR) mode is enabled - hdr-enabled",
|
||||
"Year of manufacturing - manufacture-year",
|
||||
"Nth week of manufacturing in the year - manufacture-week",
|
||||
"Serial number - serial",
|
||||
"The platform API used when detecting the display - platform-api",
|
||||
"True if the display is HDR compatible - hdr-compatible",
|
||||
"HiDPI scale factor - scale-factor",
|
||||
"Screen preferred width (in pixels) - preferred-width",
|
||||
"Screen preferred height (in pixels) - preferred-height",
|
||||
"Screen preferred refresh rate (in Hz) - preferred-refresh-rate",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_DISPLAY_MODULE_NAME,
|
||||
.description = "Print resolutions, refresh rates, etc",
|
||||
.parseCommandOptions = (void*) ffParseDisplayCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseDisplayJsonObject,
|
||||
.printModule = (void*) ffPrintDisplay,
|
||||
.generateJsonResult = (void*) ffGenerateDisplayJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateDisplayJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Screen configured width (in pixels)", "width"},
|
||||
{"Screen configured height (in pixels)", "height"},
|
||||
{"Screen configured refresh rate (in Hz)", "refresh-rate"},
|
||||
{"Screen scaled width (in pixels)", "scaled-width"},
|
||||
{"Screen scaled height (in pixels)", "scaled-height"},
|
||||
{"Screen name", "name"},
|
||||
{"Screen type (builtin, external or unknown)", "type"},
|
||||
{"Screen rotation (in degrees)", "rotation"},
|
||||
{"True if being the primary screen", "is-primary"},
|
||||
{"Screen physical width (in millimeters)", "physical-width"},
|
||||
{"Screen physical height (in millimeters)", "physical-height"},
|
||||
{"Physical diagonal length in inches", "inch"},
|
||||
{"Pixels per inch (PPI)", "ppi"},
|
||||
{"Bits per color channel", "bit-depth"},
|
||||
{"True if high dynamic range (HDR) mode is enabled", "hdr-enabled"},
|
||||
{"Year of manufacturing", "manufacture-year"},
|
||||
{"Nth week of manufacturing in the year", "manufacture-week"},
|
||||
{"Serial number", "serial"},
|
||||
{"The platform API used when detecting the display", "platform-api"},
|
||||
{"True if the display is HDR compatible", "hdr-compatible"},
|
||||
{"HiDPI scale factor", "scale-factor"},
|
||||
{"Screen preferred width (in pixels)", "preferred-width"},
|
||||
{"Screen preferred height (in pixels)", "preferred-height"},
|
||||
{"Screen preferred refresh rate (in Hz)", "preferred-refresh-rate"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitDisplayOptions(FFDisplayOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_DISPLAY_MODULE_NAME,
|
||||
"Print resolutions, refresh rates, etc",
|
||||
ffParseDisplayCommandOptions,
|
||||
ffParseDisplayJsonObject,
|
||||
ffPrintDisplay,
|
||||
ffGenerateDisplayJsonResult,
|
||||
ffPrintDisplayHelpFormat,
|
||||
ffGenerateDisplayJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->compactType = FF_DISPLAY_COMPACT_TYPE_NONE;
|
||||
options->preciseRefreshRate = false;
|
||||
|
||||
+14
-20
@@ -4,8 +4,6 @@
|
||||
#include "modules/dns/dns.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_DNS_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintDNS(FFDNSOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFstrbuf));
|
||||
@@ -48,7 +46,7 @@ void ffPrintDNS(FFDNSOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DNS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_DNS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_DNS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(buf, "result"),
|
||||
}));
|
||||
}
|
||||
@@ -166,26 +164,22 @@ exit:
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintDNSHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DNS_MODULE_NAME, "{1}", FF_DNS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"DNS result - result",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_DNS_MODULE_NAME,
|
||||
.description = "Print configured DNS servers",
|
||||
.parseCommandOptions = (void*) ffParseDNSCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseDNSJsonObject,
|
||||
.printModule = (void*) ffPrintDNS,
|
||||
.generateJsonResult = (void*) ffGenerateDNSJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateDNSJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"DNS result", "result"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitDNSOptions(FFDNSOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_DNS_MODULE_NAME,
|
||||
"Print configured DNS servers",
|
||||
ffParseDNSCommandOptions,
|
||||
ffParseDNSJsonObject,
|
||||
ffPrintDNS,
|
||||
ffGenerateDNSJsonResult,
|
||||
ffPrintDNSHelpFormat,
|
||||
ffGenerateDNSJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->showType = FF_DNS_TYPE_BOTH;
|
||||
|
||||
+18
-24
@@ -5,8 +5,6 @@
|
||||
#include "modules/editor/editor.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_EDITOR_NUM_FORMAT_ARGS 5
|
||||
|
||||
void ffPrintEditor(FFEditorOptions* options)
|
||||
{
|
||||
FFEditorResult result = {
|
||||
@@ -41,7 +39,7 @@ void ffPrintEditor(FFEditorOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_EDITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_EDITOR_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_EDITOR_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result.type, "type"),
|
||||
FF_FORMAT_ARG(result.name, "name"),
|
||||
FF_FORMAT_ARG(result.exe, "exe-name"),
|
||||
@@ -120,30 +118,26 @@ void ffGenerateEditorJsonResult(FF_MAYBE_UNUSED FFEditorOptions* options, yyjson
|
||||
ffStrbufDestroy(&result.version);
|
||||
}
|
||||
|
||||
void ffPrintEditorHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_EDITOR_MODULE_NAME, "{2} ({4})", FF_EDITOR_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Type (Visual / Editor) - type",
|
||||
"Name - name",
|
||||
"Exe name of real path - exe-name",
|
||||
"Full path of real path - full-path",
|
||||
"Version - version",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_EDITOR_MODULE_NAME,
|
||||
.description = "Print information of the default editor ($VISUAL or $EDITOR)",
|
||||
.parseCommandOptions = (void*) ffParseEditorCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseEditorJsonObject,
|
||||
.printModule = (void*) ffPrintEditor,
|
||||
.generateJsonResult = (void*) ffGenerateEditorJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateEditorJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Type (Visual / Editor)", "type"},
|
||||
{"Name", "name"},
|
||||
{"Exe name of real path", "exe-name"},
|
||||
{"Full path of real path", "full-path"},
|
||||
{"Version", "version"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitEditorOptions(FFEditorOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_EDITOR_MODULE_NAME,
|
||||
"Print information of the default editor ($VISUAL or $EDITOR)",
|
||||
ffParseEditorCommandOptions,
|
||||
ffParseEditorJsonObject,
|
||||
ffPrintEditor,
|
||||
ffGenerateEditorJsonResult,
|
||||
ffPrintEditorHelpFormat,
|
||||
ffGenerateEditorJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+18
-24
@@ -4,8 +4,6 @@
|
||||
#include "modules/font/font.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_FONT_NUM_FORMAT_ARGS (FF_DETECT_FONT_NUM_FONTS + 1)
|
||||
|
||||
void ffPrintFont(FFFontOptions* options)
|
||||
{
|
||||
FFFontResult font;
|
||||
@@ -28,7 +26,7 @@ void ffPrintFont(FFFontOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_FONT_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_FONT_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(font.fonts[0], "font1"),
|
||||
FF_FORMAT_ARG(font.fonts[1], "font2"),
|
||||
FF_FORMAT_ARG(font.fonts[2], "font3"),
|
||||
@@ -104,30 +102,26 @@ void ffGenerateFontJsonResult(FF_MAYBE_UNUSED FFFontOptions* options, yyjson_mut
|
||||
ffStrbufDestroy(&font.fonts[i]);
|
||||
}
|
||||
|
||||
void ffPrintFontHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_FONT_MODULE_NAME, "{5}", FF_FONT_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Font 1 - font1",
|
||||
"Font 2 - font2",
|
||||
"Font 3 - font3",
|
||||
"Font 4 - font4",
|
||||
"Combined fonts for display - combined"
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_FONT_MODULE_NAME,
|
||||
.description = "Print system font name",
|
||||
.parseCommandOptions = (void*) ffParseFontCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseFontJsonObject,
|
||||
.printModule = (void*) ffPrintFont,
|
||||
.generateJsonResult = (void*) ffGenerateFontJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateFontJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Font 1", "font1"},
|
||||
{"Font 2", "font2"},
|
||||
{"Font 3", "font3"},
|
||||
{"Font 4", "font4"},
|
||||
{"Combined fonts for display", "combined"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitFontOptions(FFFontOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_FONT_MODULE_NAME,
|
||||
"Print system font name",
|
||||
ffParseFontCommandOptions,
|
||||
ffParseFontJsonObject,
|
||||
ffPrintFont,
|
||||
ffGenerateFontJsonResult,
|
||||
ffPrintFontHelpFormat,
|
||||
ffGenerateFontJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "modules/gamepad/gamepad.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_GAMEPAD_NUM_FORMAT_ARGS 4
|
||||
|
||||
static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device, uint8_t index)
|
||||
{
|
||||
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
|
||||
@@ -43,7 +41,7 @@ static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&percentageBar, device->battery, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_GAMEPAD_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->name, "name"),
|
||||
FF_FORMAT_ARG(device->serial, "serial"),
|
||||
FF_FORMAT_ARG(percentageNum, "battery-percentage"),
|
||||
@@ -149,29 +147,25 @@ void ffGenerateGamepadJsonResult(FF_MAYBE_UNUSED FFGamepadOptions* options, yyjs
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintGamepadHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_GAMEPAD_MODULE_NAME, "{1} ({3})", FF_GAMEPAD_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name - name",
|
||||
"Serial number - serial",
|
||||
"Battery percentage num - battery-percentage",
|
||||
"Battery percentage bar - battery-percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_GAMEPAD_MODULE_NAME,
|
||||
.description = "List (connected) gamepads",
|
||||
.parseCommandOptions = (void*) ffParseGamepadCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseGamepadJsonObject,
|
||||
.printModule = (void*) ffPrintGamepad,
|
||||
.generateJsonResult = (void*) ffGenerateGamepadJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateGamepadJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name", "name"},
|
||||
{"Serial number", "serial"},
|
||||
{"Battery percentage num", "battery-percentage"},
|
||||
{"Battery percentage bar", "battery-percentage-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitGamepadOptions(FFGamepadOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_GAMEPAD_MODULE_NAME,
|
||||
"List connected gamepads",
|
||||
ffParseGamepadCommandOptions,
|
||||
ffParseGamepadJsonObject,
|
||||
ffPrintGamepad,
|
||||
ffGenerateGamepadJsonResult,
|
||||
ffPrintGamepadHelpFormat,
|
||||
ffGenerateGamepadJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 20, 0 };
|
||||
}
|
||||
|
||||
+26
-32
@@ -10,8 +10,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FF_GPU_NUM_FORMAT_ARGS 13
|
||||
|
||||
static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResult* gpu)
|
||||
{
|
||||
const char* type;
|
||||
@@ -90,7 +88,7 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
|
||||
FF_STRBUF_AUTO_DESTROY frequency = ffStrbufCreate();
|
||||
ffParseFrequency(gpu->frequency, &frequency);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_GPU_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(gpu->vendor, "vendor"),
|
||||
FF_FORMAT_ARG(gpu->name, "name"),
|
||||
FF_FORMAT_ARG(gpu->driver, "driver"),
|
||||
@@ -394,38 +392,34 @@ void ffGenerateGPUJsonResult(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintGPUHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_GPU_MODULE_NAME, "{1} {2}", FF_GPU_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"GPU vendor - vendor",
|
||||
"GPU name - name",
|
||||
"GPU driver - driver",
|
||||
"GPU temperature - temperature",
|
||||
"GPU core count - core-count",
|
||||
"GPU type - type",
|
||||
"GPU total dedicated memory - dedicated-total",
|
||||
"GPU used dedicated memory - dedicated-used",
|
||||
"GPU total shared memory - shared-total",
|
||||
"GPU used shared memory - shared-used",
|
||||
"The platform API used when detecting the GPU - platform-api",
|
||||
"Current frequency in GHz - frequency",
|
||||
"GPU vendor specific index - index",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_GPU_MODULE_NAME,
|
||||
.description = "Print GPU names, graphic memory size, type, etc",
|
||||
.parseCommandOptions = (void*) ffParseGPUCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseGPUJsonObject,
|
||||
.printModule = (void*) ffPrintGPU,
|
||||
.generateJsonResult = (void*) ffGenerateGPUJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateGPUJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"GPU vendor", "vendor"},
|
||||
{"GPU name", "name"},
|
||||
{"GPU driver", "driver"},
|
||||
{"GPU temperature", "temperature"},
|
||||
{"GPU core count", "core-count"},
|
||||
{"GPU type", "type"},
|
||||
{"GPU total dedicated memory", "dedicated-total"},
|
||||
{"GPU used dedicated memory", "dedicated-used"},
|
||||
{"GPU total shared memory", "shared-total"},
|
||||
{"GPU used shared memory", "shared-used"},
|
||||
{"The platform API used when detecting the GPU", "platform-api"},
|
||||
{"Current frequency in GHz", "frequency"},
|
||||
{"GPU vendor specific index", "index"},
|
||||
})),
|
||||
};
|
||||
|
||||
void ffInitGPUOptions(FFGPUOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_GPU_MODULE_NAME,
|
||||
"Print GPU names, graphic memory size, type, etc",
|
||||
ffParseGPUCommandOptions,
|
||||
ffParseGPUJsonObject,
|
||||
ffPrintGPU,
|
||||
ffGenerateGPUJsonResult,
|
||||
ffPrintGPUHelpFormat,
|
||||
ffGenerateGPUJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->driverSpecific = false;
|
||||
|
||||
+20
-26
@@ -4,8 +4,6 @@
|
||||
#include "modules/host/host.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_HOST_NUM_FORMAT_ARGS 7
|
||||
|
||||
void ffPrintHost(FFHostOptions* options)
|
||||
{
|
||||
FFHostResult host;
|
||||
@@ -48,7 +46,7 @@ void ffPrintHost(FFHostOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_HOST_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(host.family, "family"),
|
||||
FF_FORMAT_ARG(host.name, "name"),
|
||||
FF_FORMAT_ARG(host.version, "version"),
|
||||
@@ -147,32 +145,28 @@ exit:
|
||||
ffStrbufDestroy(&host.vendor);
|
||||
}
|
||||
|
||||
void ffPrintHostHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_HOST_MODULE_NAME, "{2} {3}", FF_HOST_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"product family - family",
|
||||
"product name - name",
|
||||
"product version - version",
|
||||
"product sku - sku",
|
||||
"product vendor - vendor",
|
||||
"product serial number - serial",
|
||||
"product uuid - uuid",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_HOST_MODULE_NAME,
|
||||
.description = "Print product name of your computer",
|
||||
.parseCommandOptions = (void*) ffParseHostCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseHostJsonObject,
|
||||
.printModule = (void*) ffPrintHost,
|
||||
.generateJsonResult = (void*) ffGenerateHostJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateHostJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Product family", "family"},
|
||||
{"Product name", "name"},
|
||||
{"Product version", "version"},
|
||||
{"Product sku", "sku"},
|
||||
{"Product vendor", "vendor"},
|
||||
{"Product serial number", "serial"},
|
||||
{"Product uuid", "uuid"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitHostOptions(FFHostOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_HOST_MODULE_NAME,
|
||||
"Print product name of your computer",
|
||||
ffParseHostCommandOptions,
|
||||
ffParseHostJsonObject,
|
||||
ffPrintHost,
|
||||
ffGenerateHostJsonResult,
|
||||
ffPrintHostHelpFormat,
|
||||
ffGenerateHostJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+15
-21
@@ -4,8 +4,6 @@
|
||||
#include "modules/icons/icons.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_ICONS_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintIcons(FFIconsOptions* options)
|
||||
{
|
||||
FFIconsResult result = {
|
||||
@@ -35,7 +33,7 @@ void ffPrintIcons(FFIconsOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_ICONS_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_ICONS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result.icons1, "icons1"),
|
||||
FF_FORMAT_ARG(result.icons2, "icons2"),
|
||||
}));
|
||||
@@ -102,27 +100,23 @@ void ffGenerateIconsJsonResult(FF_MAYBE_UNUSED FFIconsOptions* options, yyjson_m
|
||||
ffStrbufDestroy(&result.icons2);
|
||||
}
|
||||
|
||||
void ffPrintIconsHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_ICONS_MODULE_NAME, "{1}, {2}", FF_ICONS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Icons part 1 - icons1",
|
||||
"Icons part 2 - icons2",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_ICONS_MODULE_NAME,
|
||||
.description = "Print icon style name",
|
||||
.parseCommandOptions = (void*) ffParseIconsCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseIconsJsonObject,
|
||||
.printModule = (void*) ffPrintIcons,
|
||||
.generateJsonResult = (void*) ffGenerateIconsJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateIconsJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Icons part 1", "icons1"},
|
||||
{"Icons part 2", "icons2"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitIconsOptions(FFIconsOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_ICONS_MODULE_NAME,
|
||||
"Print icon style name",
|
||||
ffParseIconsCommandOptions,
|
||||
ffParseIconsJsonObject,
|
||||
ffPrintIcons,
|
||||
ffGenerateIconsJsonResult,
|
||||
ffPrintIconsHelpFormat,
|
||||
ffGenerateIconsJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "modules/initsystem/initsystem.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_INITSYSTEM_NUM_FORMAT_ARGS 4
|
||||
#define FF_INITSYSTEM_DISPLAY_NAME "Init System"
|
||||
|
||||
void ffPrintInitSystem(FFInitSystemOptions* options)
|
||||
@@ -35,7 +34,7 @@ void ffPrintInitSystem(FFInitSystemOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_INITSYSTEM_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_INITSYSTEM_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_INITSYSTEM_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.name, "name"),
|
||||
FF_FORMAT_ARG(result.exe, "exe"),
|
||||
FF_FORMAT_ARG(result.version, "version"),
|
||||
@@ -113,29 +112,25 @@ exit:
|
||||
ffStrbufDestroy(&result.version);
|
||||
}
|
||||
|
||||
void ffPrintInitSystemHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_INITSYSTEM_DISPLAY_NAME, "{1}", FF_INITSYSTEM_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"init system name - name",
|
||||
"init system exe path - exe",
|
||||
"init system version path - version",
|
||||
"init system pid - pid",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_INITSYSTEM_MODULE_NAME,
|
||||
.description = "Print init system (pid 1) name and version",
|
||||
.parseCommandOptions = (void*) ffParseInitSystemCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseInitSystemJsonObject,
|
||||
.printModule = (void*) ffPrintInitSystem,
|
||||
.generateJsonResult = (void*) ffGenerateInitSystemJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateInitSystemJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Init system name", "name"},
|
||||
{"Init system exe path", "exe"},
|
||||
{"Init system version path", "version"},
|
||||
{"Init system pid", "pid"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitInitSystemOptions(FFInitSystemOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_INITSYSTEM_MODULE_NAME,
|
||||
"Print init system (pid 1) name and version",
|
||||
ffParseInitSystemCommandOptions,
|
||||
ffParseInitSystemJsonObject,
|
||||
ffPrintInitSystem,
|
||||
ffGenerateInitSystemJsonResult,
|
||||
ffPrintInitSystemHelpFormat,
|
||||
ffGenerateInitSystemJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+19
-25
@@ -3,8 +3,6 @@
|
||||
#include "modules/kernel/kernel.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_KERNEL_NUM_FORMAT_ARGS 6
|
||||
|
||||
void ffPrintKernel(FFKernelOptions* options)
|
||||
{
|
||||
const FFPlatformSysinfo* info = &instance.state.platform.sysinfo;
|
||||
@@ -22,7 +20,7 @@ void ffPrintKernel(FFKernelOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
ffParseSize(info->pageSize, &str);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_KERNEL_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(info->name, "sysname"),
|
||||
FF_FORMAT_ARG(info->release, "release"),
|
||||
FF_FORMAT_ARG(info->version, "version"),
|
||||
@@ -81,31 +79,27 @@ void ffGenerateKernelJsonResult(FF_MAYBE_UNUSED FFKernelOptions* options, yyjson
|
||||
yyjson_mut_obj_add_uint(doc, obj, "pageSize", info->pageSize);
|
||||
}
|
||||
|
||||
void ffPrintKernelHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_KERNEL_MODULE_NAME, "{1} {2}", FF_KERNEL_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Sysname - sysname",
|
||||
"Release - release",
|
||||
"Version - version",
|
||||
"Architecture - arch",
|
||||
"Display version - display-version",
|
||||
"Page size - page-size",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_KERNEL_MODULE_NAME,
|
||||
.description = "Print system kernel version",
|
||||
.parseCommandOptions = (void*) ffParseKernelCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseKernelJsonObject,
|
||||
.printModule = (void*) ffPrintKernel,
|
||||
.generateJsonResult = (void*) ffGenerateKernelJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateKernelJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Sysname", "sysname"},
|
||||
{"Release", "release"},
|
||||
{"Version", "version"},
|
||||
{"Architecture", "arch"},
|
||||
{"Display version", "display-version"},
|
||||
{"Page size", "page-size"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitKernelOptions(FFKernelOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_KERNEL_MODULE_NAME,
|
||||
"Print system kernel version",
|
||||
ffParseKernelCommandOptions,
|
||||
ffParseKernelJsonObject,
|
||||
ffPrintKernel,
|
||||
ffGenerateKernelJsonResult,
|
||||
ffPrintKernelHelpFormat,
|
||||
ffGenerateKernelJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "modules/keyboard/keyboard.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_KEYBOARD_NUM_FORMAT_ARGS 2
|
||||
|
||||
static void printDevice(FFKeyboardOptions* options, const FFKeyboardDevice* device, uint8_t index)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
@@ -16,7 +14,7 @@ static void printDevice(FFKeyboardOptions* options, const FFKeyboardDevice* devi
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_KEYBOARD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_KEYBOARD_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_KEYBOARD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->name, "name"),
|
||||
FF_FORMAT_ARG(device->serial, "serial"),
|
||||
}));
|
||||
@@ -112,27 +110,23 @@ void ffGenerateKeyboardJsonResult(FF_MAYBE_UNUSED FFKeyboardOptions* options, yy
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintKeyboardHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_KEYBOARD_MODULE_NAME, "{1} ({3})", FF_KEYBOARD_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name - name",
|
||||
"Serial number - serial",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_KEYBOARD_MODULE_NAME,
|
||||
.description = "List (connected) keyboards",
|
||||
.parseCommandOptions = (void*) ffParseKeyboardCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseKeyboardJsonObject,
|
||||
.printModule = (void*) ffPrintKeyboard,
|
||||
.generateJsonResult = (void*) ffGenerateKeyboardJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateKeyboardJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name", "name"},
|
||||
{"Serial number", "serial"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitKeyboardOptions(FFKeyboardOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_KEYBOARD_MODULE_NAME,
|
||||
"List connected keyboards",
|
||||
ffParseKeyboardCommandOptions,
|
||||
ffParseKeyboardJsonObject,
|
||||
ffPrintKeyboard,
|
||||
ffGenerateKeyboardJsonResult,
|
||||
ffPrintKeyboardHelpFormat,
|
||||
ffGenerateKeyboardJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+16
-22
@@ -4,8 +4,6 @@
|
||||
#include "modules/lm/lm.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_LM_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintLM(FFLMOptions* options)
|
||||
{
|
||||
FFLMResult result;
|
||||
@@ -38,7 +36,7 @@ void ffPrintLM(FFLMOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LM_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result.service, "service"),
|
||||
FF_FORMAT_ARG(result.type, "type"),
|
||||
FF_FORMAT_ARG(result.version, "version"),
|
||||
@@ -115,28 +113,24 @@ exit:
|
||||
ffStrbufDestroy(&result.version);
|
||||
}
|
||||
|
||||
void ffPrintLMHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LM_MODULE_NAME, "{1} {3} ({2})", FF_LM_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"LM service - service",
|
||||
"LM type - type",
|
||||
"LM version - version"
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_LM_MODULE_NAME,
|
||||
.description = "Print login manager (desktop manager) name and version",
|
||||
.parseCommandOptions = (void*) ffParseLMCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseLMJsonObject,
|
||||
.printModule = (void*) ffPrintLM,
|
||||
.generateJsonResult = (void*) ffGenerateLMJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateLMJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"LM service", "service"},
|
||||
{"LM type", "type"},
|
||||
{"LM version", "version"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitLMOptions(FFLMOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_LM_MODULE_NAME,
|
||||
"Print login manager (desktop manager) name and version",
|
||||
ffParseLMCommandOptions,
|
||||
ffParseLMJsonObject,
|
||||
ffPrintLM,
|
||||
ffGenerateLMJsonResult,
|
||||
ffPrintLMHelpFormat,
|
||||
ffGenerateLMJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#include "modules/loadavg/loadavg.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_LOADAVG_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintLoadavg(FFLoadavgOptions* options)
|
||||
{
|
||||
double result[3] = { 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0 };
|
||||
@@ -48,7 +46,7 @@ void ffPrintLoadavg(FFLoadavgOptions* options)
|
||||
else
|
||||
{
|
||||
ffStrbufClear(&buffer);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(duration, "duration"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -84,7 +82,7 @@ void ffPrintLoadavg(FFLoadavgOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LOADAVG_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LOADAVG_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LOADAVG_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result[0], "loadavg1"),
|
||||
FF_FORMAT_ARG(result[1], "loadavg2"),
|
||||
FF_FORMAT_ARG(result[2], "loadavg3"),
|
||||
@@ -181,28 +179,24 @@ void ffGenerateLoadavgJsonResult(FF_MAYBE_UNUSED FFLoadavgOptions* options, yyjs
|
||||
yyjson_mut_arr_add_real(doc, arr, result[i]);
|
||||
}
|
||||
|
||||
void ffPrintLoadavgHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOADAVG_MODULE_NAME, "{1}, {2}, {3}", FF_LOADAVG_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Load average over 1min - loadavg1",
|
||||
"Load average over 5min - loadavg2",
|
||||
"Load average over 15min - loadavg3",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_LOADAVG_MODULE_NAME,
|
||||
.description = "Print system load averages",
|
||||
.parseCommandOptions = (void*) ffParseLoadavgCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseLoadavgJsonObject,
|
||||
.printModule = (void*) ffPrintLoadavg,
|
||||
.generateJsonResult = (void*) ffGenerateLoadavgJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateLoadavgJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Load average over 1min", "loadavg1"},
|
||||
{"Load average over 5min", "loadavg2"},
|
||||
{"Load average over 15min", "loadavg3"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitLoadavgOptions(FFLoadavgOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_LOADAVG_MODULE_NAME,
|
||||
"Print system load averages",
|
||||
ffParseLoadavgCommandOptions,
|
||||
ffParseLoadavgJsonObject,
|
||||
ffPrintLoadavg,
|
||||
ffGenerateLoadavgJsonResult,
|
||||
ffPrintLoadavgHelpFormat,
|
||||
ffGenerateLoadavgJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 80, 0 };
|
||||
|
||||
+14
-20
@@ -4,8 +4,6 @@
|
||||
#include "modules/locale/locale.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_LOCALE_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintLocale(FFLocaleOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY locale = ffStrbufCreate();
|
||||
@@ -24,7 +22,7 @@ void ffPrintLocale(FFLocaleOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_LOCALE_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_LOCALE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(locale, "result")
|
||||
}));
|
||||
}
|
||||
@@ -79,26 +77,22 @@ void ffGenerateLocaleJsonResult(FF_MAYBE_UNUSED FFLocaleOptions* options, yyjson
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "result", &locale);
|
||||
}
|
||||
|
||||
void ffPrintLocaleHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOCALE_MODULE_NAME, "{1}", FF_LOCALE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Locale code - result"
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_LOCALE_MODULE_NAME,
|
||||
.description = "Print system locale name",
|
||||
.parseCommandOptions = (void*) ffParseLocaleCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseLocaleJsonObject,
|
||||
.printModule = (void*) ffPrintLocale,
|
||||
.generateJsonResult = (void*) ffGenerateLocaleJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateLocaleJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Locale code", "result"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitLocaleOptions(FFLocaleOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_LOCALE_MODULE_NAME,
|
||||
"Print system locale name",
|
||||
ffParseLocaleCommandOptions,
|
||||
ffParseLocaleJsonObject,
|
||||
ffPrintLocale,
|
||||
ffGenerateLocaleJsonResult,
|
||||
ffPrintLocaleHelpFormat,
|
||||
ffGenerateLocaleJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_LOCALIP_DISPLAY_NAME "Local IP"
|
||||
#define FF_LOCALIP_NUM_FORMAT_ARGS 8
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
|
||||
static int sortIps(const FFLocalIpResult* left, const FFLocalIpResult* right)
|
||||
@@ -25,7 +24,7 @@ static void formatKey(const FFLocalIpOptions* options, FFLocalIpResult* ip, uint
|
||||
else
|
||||
{
|
||||
ffStrbufClear(key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 4, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(ip->name, "name"),
|
||||
FF_FORMAT_ARG(ip->mac, "mac"),
|
||||
@@ -149,7 +148,7 @@ void ffPrintLocalIp(FFLocalIpOptions* options)
|
||||
else
|
||||
ffStrbufSetF(&speedStr, "%u Mbps", (unsigned) ip->speed);
|
||||
}
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_LOCALIP_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(ip->ipv4, "ipv4"),
|
||||
FF_FORMAT_ARG(ip->ipv6, "ipv6"),
|
||||
FF_FORMAT_ARG(ip->mac, "mac"),
|
||||
@@ -500,33 +499,29 @@ void ffGenerateLocalIpJsonResult(FF_MAYBE_UNUSED FFLocalIpOptions* options, yyjs
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintLocalIpHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_LOCALIP_MODULE_NAME, "{1}", FF_LOCALIP_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Local IPv4 address - ipv4",
|
||||
"Local IPv6 address - ipv6",
|
||||
"Physical (MAC) address - mac",
|
||||
"Interface name - ifname",
|
||||
"Is default route - is-default-route",
|
||||
"MTU size in bytes - mtu",
|
||||
"Link speed (formatted) - speed",
|
||||
"Interface flags - flags",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_LOCALIP_MODULE_NAME,
|
||||
.description = "List local IP addresses (v4 or v6), MAC addresses, etc",
|
||||
.parseCommandOptions = (void*) ffParseLocalIpCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseLocalIpJsonObject,
|
||||
.printModule = (void*) ffPrintLocalIp,
|
||||
.generateJsonResult = (void*) ffGenerateLocalIpJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateLocalIpJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"IPv4 address", "ipv4"},
|
||||
{"IPv6 address", "ipv6"},
|
||||
{"MAC address", "mac"},
|
||||
{"Interface name", "ifname"},
|
||||
{"Is default route", "is-default-route"},
|
||||
{"MTU size in bytes", "mtu"},
|
||||
{"Link speed (formatted)", "speed"},
|
||||
{"Interface flags", "flags"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitLocalIpOptions(FFLocalIpOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_LOCALIP_MODULE_NAME,
|
||||
"List local IP addresses (v4 or v6), MAC addresses, etc",
|
||||
ffParseLocalIpCommandOptions,
|
||||
ffParseLocalIpJsonObject,
|
||||
ffPrintLocalIp,
|
||||
ffGenerateLocalIpJsonResult,
|
||||
ffPrintLocalIpHelpFormat,
|
||||
ffGenerateLocalIpJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->showType = FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_PREFIX_LEN_BIT
|
||||
|
||||
+18
-24
@@ -6,8 +6,6 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#define FF_MEDIA_NUM_FORMAT_ARGS 5
|
||||
|
||||
static inline bool shouldIgnoreChar(char c)
|
||||
{
|
||||
return isblank(c) || c == '-' || c == '.';
|
||||
@@ -95,7 +93,7 @@ void ffPrintMedia(FFMediaOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MEDIA_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MEDIA_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(songPretty, "combined"),
|
||||
FF_FORMAT_ARG(media->song, "title"),
|
||||
FF_FORMAT_ARG(media->artist, "artist"),
|
||||
@@ -157,30 +155,26 @@ void ffGenerateMediaJsonResult(FF_MAYBE_UNUSED FFMediaOptions* options, yyjson_m
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "status", &media->status);
|
||||
}
|
||||
|
||||
void ffPrintMediaHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MEDIA_MODULE_NAME, "{3} - {1} ({5})", FF_MEDIA_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Pretty media name - combined",
|
||||
"Media name - title",
|
||||
"Artist name - artist",
|
||||
"Album name - album",
|
||||
"Status - status",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_MEDIA_MODULE_NAME,
|
||||
.description = "Print playing song name",
|
||||
.parseCommandOptions = (void*) ffParseMediaCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseMediaJsonObject,
|
||||
.printModule = (void*) ffPrintMedia,
|
||||
.generateJsonResult = (void*) ffGenerateMediaJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateMediaJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Pretty media name", "combined"},
|
||||
{"Media name", "title"},
|
||||
{"Artist name", "artist"},
|
||||
{"Album name", "album"},
|
||||
{"Status", "status"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitMediaOptions(FFMediaOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_MEDIA_MODULE_NAME,
|
||||
"Print playing song name",
|
||||
ffParseMediaCommandOptions,
|
||||
ffParseMediaJsonObject,
|
||||
ffPrintMedia,
|
||||
ffGenerateMediaJsonResult,
|
||||
ffPrintMediaHelpFormat,
|
||||
ffGenerateMediaJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+17
-23
@@ -6,8 +6,6 @@
|
||||
#include "modules/memory/memory.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_MEMORY_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintMemory(FFMemoryOptions* options)
|
||||
{
|
||||
FFMemoryResult storage = {};
|
||||
@@ -64,7 +62,7 @@ void ffPrintMemory(FFMemoryOptions* options)
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&percentageBar, percentage, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MEMORY_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(usedPretty, "used"),
|
||||
FF_FORMAT_ARG(totalPretty, "total"),
|
||||
FF_FORMAT_ARG(percentageNum, "percentage"),
|
||||
@@ -132,29 +130,25 @@ void ffGenerateMemoryJsonResult(FF_MAYBE_UNUSED FFMemoryOptions* options, yyjson
|
||||
yyjson_mut_obj_add_uint(doc, obj, "used", storage.bytesUsed);
|
||||
}
|
||||
|
||||
void ffPrintMemoryHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MEMORY_MODULE_NAME, "{1} / {2} ({3})", FF_MEMORY_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Used size - used",
|
||||
"Total size - total",
|
||||
"Percentage used (num) - percentage",
|
||||
"Percentage used (bar) - percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_MEMORY_MODULE_NAME,
|
||||
.description = "Print system memory usage info",
|
||||
.parseCommandOptions = (void*) ffParseMemoryCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseMemoryJsonObject,
|
||||
.printModule = (void*) ffPrintMemory,
|
||||
.generateJsonResult = (void*) ffGenerateMemoryJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateMemoryJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Used size", "used"},
|
||||
{"Total size", "total"},
|
||||
{"Percentage used (num)", "percentage"},
|
||||
{"Percentage used (bar)", "percentage-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitMemoryOptions(FFMemoryOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_MEMORY_MODULE_NAME,
|
||||
"Print system memory usage info",
|
||||
ffParseMemoryCommandOptions,
|
||||
ffParseMemoryJsonObject,
|
||||
ffPrintMemory,
|
||||
ffGenerateMemoryJsonResult,
|
||||
ffPrintMemoryHelpFormat,
|
||||
ffGenerateMemoryJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 80, 0 };
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define FF_MONITOR_NUM_FORMAT_ARGS 12
|
||||
|
||||
void ffPrintMonitor(FFMonitorOptions* options)
|
||||
{
|
||||
const FFDisplayServerResult* result = ffConnectDisplayServer();
|
||||
@@ -36,7 +34,7 @@ void ffPrintMonitor(FFMonitorOptions* options)
|
||||
else
|
||||
{
|
||||
uint32_t moduleIndex = result->displays.length == 1 ? 0 : index + 1;
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(moduleIndex, "index"),
|
||||
FF_FORMAT_ARG(display->name, "name"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -67,7 +65,7 @@ void ffPrintMonitor(FFMonitorOptions* options)
|
||||
else
|
||||
buf[0] = '\0';
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_MONITOR_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(display->name, "name"),
|
||||
FF_FORMAT_ARG(display->width, "width"),
|
||||
FF_FORMAT_ARG(display->height, "height"),
|
||||
@@ -128,37 +126,33 @@ void ffGenerateMonitorJsonResult(FF_MAYBE_UNUSED FFMonitorOptions* options, yyjs
|
||||
yyjson_mut_obj_add_str(doc, module, "error", "Monitor module is an alias of Display module");
|
||||
}
|
||||
|
||||
void ffPrintMonitorHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MONITOR_MODULE_NAME, "{2}x{3} px - {4}x{5} mm ({6} inches, {7} ppi)", FF_MONITOR_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Display name - name",
|
||||
"Native resolution width in pixels - width",
|
||||
"Native resolution height in pixels - height",
|
||||
"Physical width in millimeters - physical-width",
|
||||
"Physical height in millimeters - physical-height",
|
||||
"Physical diagonal length in inches - inch",
|
||||
"Pixels per inch (PPI) - ppi",
|
||||
"Year of manufacturing - manufacture-year",
|
||||
"Nth week of manufacturing in the year - manufacture-week",
|
||||
"Serial number - serial",
|
||||
"Maximum refresh rate in Hz - refresh-rate",
|
||||
"True if the display is HDR compatible - hdr-compatible",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_MONITOR_MODULE_NAME,
|
||||
.description = "Alias of Display module",
|
||||
.parseCommandOptions = (void*) ffParseMonitorCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseMonitorJsonObject,
|
||||
.printModule = (void*) ffPrintMonitor,
|
||||
.generateJsonResult = (void*) ffGenerateMonitorJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateMonitorJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Display name", "name"},
|
||||
{"Native resolution width in pixels", "width"},
|
||||
{"Native resolution height in pixels", "height"},
|
||||
{"Physical width in millimeters", "physical-width"},
|
||||
{"Physical height in millimeters", "physical-height"},
|
||||
{"Physical diagonal length in inches", "inch"},
|
||||
{"Pixels per inch (PPI)", "ppi"},
|
||||
{"Year of manufacturing", "manufacture-year"},
|
||||
{"Nth week of manufacturing in the year", "manufacture-week"},
|
||||
{"Serial number", "serial"},
|
||||
{"Maximum refresh rate in Hz", "refresh-rate"},
|
||||
{"True if the display is HDR compatible", "hdr-compatible"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitMonitorOptions(FFMonitorOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_MONITOR_MODULE_NAME,
|
||||
"Alias of Display module",
|
||||
ffParseMonitorCommandOptions,
|
||||
ffParseMonitorJsonObject,
|
||||
ffPrintMonitor,
|
||||
ffGenerateMonitorJsonResult,
|
||||
ffPrintMonitorHelpFormat,
|
||||
ffGenerateMonitorJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+15
-21
@@ -5,8 +5,6 @@
|
||||
#include "modules/mouse/mouse.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_MOUSE_NUM_FORMAT_ARGS 2
|
||||
|
||||
static void printDevice(FFMouseOptions* options, const FFMouseDevice* device, uint8_t index)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
@@ -16,7 +14,7 @@ static void printDevice(FFMouseOptions* options, const FFMouseDevice* device, ui
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MOUSE_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MOUSE_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MOUSE_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->name, "name"),
|
||||
FF_FORMAT_ARG(device->serial, "serial"),
|
||||
}));
|
||||
@@ -112,27 +110,23 @@ void ffGenerateMouseJsonResult(FF_MAYBE_UNUSED FFMouseOptions* options, yyjson_m
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintMouseHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MOUSE_MODULE_NAME, "{1} ({3})", FF_MOUSE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name - name",
|
||||
"Serial number - serial",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_MOUSE_MODULE_NAME,
|
||||
.description = "List connected mouses",
|
||||
.parseCommandOptions = (void*) ffParseMouseCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseMouseJsonObject,
|
||||
.printModule = (void*) ffPrintMouse,
|
||||
.generateJsonResult = (void*) ffGenerateMouseJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateMouseJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Mouse name", "name"},
|
||||
{"Mouse serial number", "serial"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitMouseOptions(FFMouseOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_MOUSE_MODULE_NAME,
|
||||
"List connected mouses",
|
||||
ffParseMouseCommandOptions,
|
||||
ffParseMouseJsonObject,
|
||||
ffPrintMouse,
|
||||
ffGenerateMouseJsonResult,
|
||||
ffPrintMouseHelpFormat,
|
||||
ffGenerateMouseJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+26
-31
@@ -6,7 +6,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_NETIO_DISPLAY_NAME "Network IO"
|
||||
#define FF_NETIO_NUM_FORMAT_ARGS 12
|
||||
|
||||
static int sortInfs(const FFNetIOResult* left, const FFNetIOResult* right)
|
||||
{
|
||||
@@ -25,7 +24,7 @@ static void formatKey(const FFNetIOOptions* options, FFNetIOResult* inf, uint32_
|
||||
else
|
||||
{
|
||||
ffStrbufClear(key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(inf->name, "name"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -80,7 +79,7 @@ void ffPrintNetIO(FFNetIOOptions* options)
|
||||
ffParseSize(inf->txBytes, &buffer2);
|
||||
if (!options->detectTotal) ffStrbufAppendS(&buffer2, "/s");
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_NETIO_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(buffer, "rx-size"),
|
||||
FF_FORMAT_ARG(buffer2, "tx-size"),
|
||||
FF_FORMAT_ARG(inf->name, "ifname"),
|
||||
@@ -229,37 +228,33 @@ void ffGenerateNetIOJsonResult(FFNetIOOptions* options, yyjson_mut_doc* doc, yyj
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintNetIOHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_NETIO_MODULE_NAME, "{1} (IN) - {2} (OUT)", FF_NETIO_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Size of data received [per second] (formatted) - rx-size",
|
||||
"Size of data sent [per second] (formatted) - tx-size",
|
||||
"Interface name - ifname",
|
||||
"Is default route - is-default-route",
|
||||
"Size of data received [per second] (in bytes) - rx-bytes",
|
||||
"Size of data sent [per second] (in bytes) - tx-bytes",
|
||||
"Number of packets received [per second] - rx-packets",
|
||||
"Number of packets sent [per second] - tx-packets",
|
||||
"Number of errors received [per second] - rx-errors",
|
||||
"Number of errors sent [per second] - tx-errors",
|
||||
"Number of packets dropped when receiving [per second] - rx-drops",
|
||||
"Number of packets dropped when sending [per second] - tx-drops",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_NETIO_MODULE_NAME,
|
||||
.description = "Print network I/O throughput",
|
||||
.parseCommandOptions = (void*) ffParseNetIOCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseNetIOJsonObject,
|
||||
.printModule = (void*) ffPrintNetIO,
|
||||
.generateJsonResult = (void*) ffGenerateNetIOJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateNetIOJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Size of data received [per second] (formatted)", "rx-size"},
|
||||
{"Size of data sent [per second] (formatted)", "tx-size"},
|
||||
{"Interface name", "ifname"},
|
||||
{"Is default route", "is-default-route"},
|
||||
{"Size of data received [per second] (in bytes)", "rx-bytes"},
|
||||
{"Size of data sent [per second] (in bytes)", "tx-bytes"},
|
||||
{"Number of packets received [per second]", "rx-packets"},
|
||||
{"Number of packets sent [per second]", "tx-packets"},
|
||||
{"Number of errors received [per second]", "rx-errors"},
|
||||
{"Number of errors sent [per second]", "tx-errors"},
|
||||
{"Number of packets dropped when receiving [per second]", "rx-drops"},
|
||||
{"Number of packets dropped when sending [per second]", "tx-drops"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitNetIOOptions(FFNetIOOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_NETIO_MODULE_NAME,
|
||||
"Print network I/O throughput",
|
||||
ffParseNetIOCommandOptions,
|
||||
ffParseNetIOJsonObject,
|
||||
ffPrintNetIO,
|
||||
ffGenerateNetIOJsonResult,
|
||||
ffPrintNetIOHelpFormat,
|
||||
ffGenerateNetIOJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffStrbufInit(&options->namePrefix);
|
||||
|
||||
+16
-22
@@ -5,8 +5,6 @@
|
||||
#include "modules/opencl/opencl.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_OPENCL_NUM_FORMAT_ARGS 3
|
||||
|
||||
void ffPrintOpenCL(FFOpenCLOptions* options)
|
||||
{
|
||||
FFOpenCLResult* result = ffDetectOpenCL();
|
||||
@@ -24,7 +22,7 @@ void ffPrintOpenCL(FFOpenCLOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_OPENCL_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OPENCL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result->version, "version"),
|
||||
FF_FORMAT_ARG(result->name, "name"),
|
||||
FF_FORMAT_ARG(result->vendor, "vendor"),
|
||||
@@ -130,28 +128,24 @@ void ffGenerateOpenCLJsonResult(FF_MAYBE_UNUSED FFOpenCLOptions* options, yyjson
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintOpenCLHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_OPENCL_MODULE_NAME, "{1}", FF_OPENCL_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Platform version - version",
|
||||
"Platform name - name",
|
||||
"Platform vendor - vendor",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_OPENCL_MODULE_NAME,
|
||||
.description = "Print highest OpenCL version supported by the GPU",
|
||||
.parseCommandOptions = (void*) ffParseOpenCLCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseOpenCLJsonObject,
|
||||
.printModule = (void*) ffPrintOpenCL,
|
||||
.generateJsonResult = (void*) ffGenerateOpenCLJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateOpenCLJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Platform version", "version"},
|
||||
{"Platform name", "name"},
|
||||
{"Platform vendor", "vendor"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitOpenCLOptions(FFOpenCLOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_OPENCL_MODULE_NAME,
|
||||
"Print highest OpenCL version supported by the GPU",
|
||||
ffParseOpenCLCommandOptions,
|
||||
ffParseOpenCLJsonObject,
|
||||
ffPrintOpenCL,
|
||||
ffGenerateOpenCLJsonResult,
|
||||
ffPrintOpenCLHelpFormat,
|
||||
ffGenerateOpenCLJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+18
-24
@@ -4,8 +4,6 @@
|
||||
#include "modules/opengl/opengl.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_OPENGL_NUM_FORMAT_ARGS 5
|
||||
|
||||
void ffPrintOpenGL(FFOpenGLOptions* options)
|
||||
{
|
||||
FFOpenGLResult result;
|
||||
@@ -29,7 +27,7 @@ void ffPrintOpenGL(FFOpenGLOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_OPENGL_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OPENGL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.version, "version"),
|
||||
FF_FORMAT_ARG(result.renderer, "renderer"),
|
||||
FF_FORMAT_ARG(result.vendor, "vendor"),
|
||||
@@ -159,30 +157,26 @@ void ffGenerateOpenGLJsonResult(FF_MAYBE_UNUSED FFOpenGLOptions* options, yyjson
|
||||
ffStrbufDestroy(&result.library);
|
||||
}
|
||||
|
||||
void ffPrintOpenGLHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_OPENGL_MODULE_NAME, "{1}", FF_OPENGL_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"version - version",
|
||||
"renderer - renderer",
|
||||
"vendor - vendor",
|
||||
"shading language version - slv",
|
||||
"ogl library used - library",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_OPENGL_MODULE_NAME,
|
||||
.description = "Print highest OpenGL version supported by the GPU",
|
||||
.parseCommandOptions = (void*) ffParseOpenGLCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseOpenGLJsonObject,
|
||||
.printModule = (void*) ffPrintOpenGL,
|
||||
.generateJsonResult = (void*) ffGenerateOpenGLJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateOpenGLJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"OpenGL version", "version"},
|
||||
{"OpenGL renderer", "renderer"},
|
||||
{"OpenGL vendor", "vendor"},
|
||||
{"OpenGL shading language version", "slv"},
|
||||
{"OpenGL library used", "library"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitOpenGLOptions(FFOpenGLOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_OPENGL_MODULE_NAME,
|
||||
"Print highest OpenGL version supported by the GPU",
|
||||
ffParseOpenGLCommandOptions,
|
||||
ffParseOpenGLJsonObject,
|
||||
ffPrintOpenGL,
|
||||
ffGenerateOpenGLJsonResult,
|
||||
ffPrintOpenGLHelpFormat,
|
||||
ffGenerateOpenGLJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->library = FF_OPENGL_LIBRARY_AUTO;
|
||||
|
||||
+25
-31
@@ -7,8 +7,6 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#define FF_OS_NUM_FORMAT_ARGS 12
|
||||
|
||||
static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result)
|
||||
{
|
||||
//Create the basic output
|
||||
@@ -111,7 +109,7 @@ void ffPrintOS(FFOSOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_OS_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(instance.state.platform.sysinfo.name, "sysname"),
|
||||
FF_FORMAT_ARG(os->name, "name"),
|
||||
FF_FORMAT_ARG(os->prettyName, "pretty-name"),
|
||||
@@ -186,37 +184,33 @@ void ffGenerateOSJsonResult(FF_MAYBE_UNUSED FFOSOptions* options, yyjson_mut_doc
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "versionID", &os->versionID);
|
||||
}
|
||||
|
||||
void ffPrintOSHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_OS_MODULE_NAME, "{3} {10} {12}", FF_OS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Name of the kernel (Linux, WIN32_NT, Darwin, FreeBSD) - sysname",
|
||||
"Name of the OS - name",
|
||||
"Pretty name of the OS - pretty-name",
|
||||
"ID of the OS - id",
|
||||
"ID like of the OS - id-like",
|
||||
"Variant of the OS - variant",
|
||||
"Variant ID of the OS - variant-id",
|
||||
"Version of the OS - version",
|
||||
"Version ID of the OS - version-id",
|
||||
"Version codename of the OS - codename",
|
||||
"Build ID of the OS - build-id",
|
||||
"Architecture of the OS - arch",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_OS_MODULE_NAME,
|
||||
.description = "Print operating system name and version",
|
||||
.parseCommandOptions = (void*) ffParseOSCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseOSJsonObject,
|
||||
.printModule = (void*) ffPrintOS,
|
||||
.generateJsonResult = (void*) ffGenerateOSJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateOSJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Name of the kernel", "sysname"},
|
||||
{"Name of the OS", "name"},
|
||||
{"Pretty name of the OS", "pretty-name"},
|
||||
{"ID of the OS", "id"},
|
||||
{"ID like of the OS", "id-like"},
|
||||
{"Variant of the OS", "variant"},
|
||||
{"Variant ID of the OS", "variant-id"},
|
||||
{"Version of the OS", "version"},
|
||||
{"Version ID of the OS", "version-id"},
|
||||
{"Version codename of the OS", "codename"},
|
||||
{"Build ID of the OS", "build-id"},
|
||||
{"Architecture of the OS", "arch"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitOSOptions(FFOSOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_OS_MODULE_NAME,
|
||||
"Print operating system name and version",
|
||||
ffParseOSCommandOptions,
|
||||
ffParseOSJsonObject,
|
||||
ffPrintOS,
|
||||
ffGenerateOSJsonResult,
|
||||
ffPrintOSHelpFormat,
|
||||
ffGenerateOSJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs,
|
||||
#ifdef _WIN32
|
||||
""
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "modules/packages/packages.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_PACKAGES_NUM_FORMAT_ARGS 40
|
||||
|
||||
void ffPrintPackages(FFPackagesOptions* options)
|
||||
{
|
||||
FFPackagesResult counts = {};
|
||||
@@ -84,7 +82,7 @@ void ffPrintPackages(FFPackagesOptions* options)
|
||||
uint32_t flatpakAll = counts.flatpakSystem + counts.flatpakUser;
|
||||
uint32_t brewAll = counts.brew + counts.brewCask;
|
||||
uint32_t guixAll = counts.guixSystem + counts.guixUser + counts.guixHome;
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PACKAGES_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PACKAGES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(counts.all, "all"),
|
||||
FF_FORMAT_ARG(counts.pacman, "pacman"),
|
||||
FF_FORMAT_ARG(counts.pacmanBranch, "pacman-branch"),
|
||||
@@ -437,65 +435,61 @@ void ffGeneratePackagesJsonResult(FF_MAYBE_UNUSED FFPackagesOptions* options, yy
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "pacmanBranch", &counts.pacmanBranch);
|
||||
}
|
||||
|
||||
void ffPrintPackagesHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PACKAGES_MODULE_NAME, "{2} (pacman){?3}[{3}]{?}, {4} (dpkg), {5} (rpm), {6} (emerge), {7} (eopkg), {8} (xbps), {9} (nix-system), {10} (nix-user), {11} (nix-default), {12} (apk), {13} (pkg), {14} (flatpak-system), {15} (flatpack-user), {16} (snap), {17} (brew), {18} (brew-cask), {19} (MacPorts), {20} (scoop), {21} (choco), {22} (pkgtool), {23} (paludis), {24} (winget), {25} (opkg), {26} (am), {27} (sorcery), {28} (lpkg), {29} (lpkgbuild), {30} (guix-system), {31} (guix-user), {32} (guix-home), {33} (linglong), {34} (pacstall), {35} (mport), {36} qi", FF_PACKAGES_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Number of all packages - all",
|
||||
"Number of pacman packages - pacman",
|
||||
"Pacman branch on manjaro - pacman-branch",
|
||||
"Number of dpkg packages - dpkg",
|
||||
"Number of rpm packages - rpm",
|
||||
"Number of emerge packages - emerge",
|
||||
"Number of eopkg packages - eopkg",
|
||||
"Number of xbps packages - xbps",
|
||||
"Number of nix-system packages - nix-system",
|
||||
"Number of nix-user packages - nix-user",
|
||||
"Number of nix-default packages - nix-default",
|
||||
"Number of apk packages - apk",
|
||||
"Number of pkg packages - pkg",
|
||||
"Number of flatpak-system app packages - flatpak-system",
|
||||
"Number of flatpak-user app packages - flatpak-user",
|
||||
"Number of snap packages - snap",
|
||||
"Number of brew packages - brew",
|
||||
"Number of brew-cask packages - brew-cask",
|
||||
"Number of macports packages - macports",
|
||||
"Number of scoop packages - scoop",
|
||||
"Number of choco packages - choco",
|
||||
"Number of pkgtool packages - pkgtool",
|
||||
"Number of paludis packages - paludis",
|
||||
"Number of winget packages - winget",
|
||||
"Number of opkg packages - opkg",
|
||||
"Number of am packages - am",
|
||||
"Number of sorcery packages - sorcery",
|
||||
"Number of lpkg packages - lpkg",
|
||||
"Number of lpkgbuild packages - lpkgbuild",
|
||||
"Number of guix-system packages - guix-system",
|
||||
"Number of guix-user packages - guix-user",
|
||||
"Number of guix-home packages - guix-home",
|
||||
"Number of linglong packages - linglong",
|
||||
"Number of pacstall packages - pacstall",
|
||||
"Number of mport packages - mport",
|
||||
"Number of qi packages - qi",
|
||||
"Total number of all nix packages - nix-all",
|
||||
"Total number of all flatpak app packages - flatpak-all",
|
||||
"Total number of all brew packages - brew-all",
|
||||
"Total number of all guix packages - guix-all",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_PACKAGES_MODULE_NAME,
|
||||
.description = "List installed package managers and count of installed packages",
|
||||
.parseCommandOptions = (void*) ffParsePackagesCommandOptions,
|
||||
.parseJsonObject = (void*) ffParsePackagesJsonObject,
|
||||
.printModule = (void*) ffPrintPackages,
|
||||
.generateJsonResult = (void*) ffGeneratePackagesJsonResult,
|
||||
.generateJsonConfig = (void*) ffGeneratePackagesJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Number of all packages", "all"},
|
||||
{"Number of pacman packages", "pacman"},
|
||||
{"Pacman branch on manjaro", "pacman-branch"},
|
||||
{"Number of dpkg packages", "dpkg"},
|
||||
{"Number of rpm packages", "rpm"},
|
||||
{"Number of emerge packages", "emerge"},
|
||||
{"Number of eopkg packages", "eopkg"},
|
||||
{"Number of xbps packages", "xbps"},
|
||||
{"Number of nix-system packages", "nix-system"},
|
||||
{"Number of nix-user packages", "nix-user"},
|
||||
{"Number of nix-default packages", "nix-default"},
|
||||
{"Number of apk packages", "apk"},
|
||||
{"Number of pkg packages", "pkg"},
|
||||
{"Number of flatpak-system app packages", "flatpak-system"},
|
||||
{"Number of flatpak-user app packages", "flatpak-user"},
|
||||
{"Number of snap packages", "snap"},
|
||||
{"Number of brew packages", "brew"},
|
||||
{"Number of brew-cask packages", "brew-cask"},
|
||||
{"Number of macports packages", "macports"},
|
||||
{"Number of scoop packages", "scoop"},
|
||||
{"Number of choco packages", "choco"},
|
||||
{"Number of pkgtool packages", "pkgtool"},
|
||||
{"Number of paludis packages", "paludis"},
|
||||
{"Number of winget packages", "winget"},
|
||||
{"Number of opkg packages", "opkg"},
|
||||
{"Number of am packages", "am"},
|
||||
{"Number of sorcery packages", "sorcery"},
|
||||
{"Number of lpkg packages", "lpkg"},
|
||||
{"Number of lpkgbuild packages", "lpkgbuild"},
|
||||
{"Number of guix-system packages", "guix-system"},
|
||||
{"Number of guix-user packages", "guix-user"},
|
||||
{"Number of guix-home packages", "guix-home"},
|
||||
{"Number of linglong packages", "linglong"},
|
||||
{"Number of pacstall packages", "pacstall"},
|
||||
{"Number of mport packages", "mport"},
|
||||
{"Number of qi packages", "qi"},
|
||||
{"Total number of all nix packages", "nix-all"},
|
||||
{"Total number of all flatpak app packages", "flatpak-all"},
|
||||
{"Total number of all brew packages", "brew-all"},
|
||||
{"Total number of all guix packages", "guix-all"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitPackagesOptions(FFPackagesOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_PACKAGES_MODULE_NAME,
|
||||
"List installed package managers and count of installed packages",
|
||||
ffParsePackagesCommandOptions,
|
||||
ffParsePackagesJsonObject,
|
||||
ffPrintPackages,
|
||||
ffGeneratePackagesJsonResult,
|
||||
ffPrintPackagesHelpFormat,
|
||||
ffGeneratePackagesJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->disabled = FF_PACKAGES_DISABLE_LIST;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_PHYSICALDISK_DISPLAY_NAME "Physical Disk"
|
||||
#define FF_PHYSICALDISK_NUM_FORMAT_ARGS 10
|
||||
|
||||
static int sortDevices(const FFPhysicalDiskResult* left, const FFPhysicalDiskResult* right)
|
||||
{
|
||||
@@ -23,7 +22,7 @@ static void formatKey(const FFPhysicalDiskOptions* options, FFPhysicalDiskResult
|
||||
else
|
||||
{
|
||||
ffStrbufClear(key);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, 4, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(key, &options->moduleArgs.key, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(dev->name, "name"),
|
||||
FF_FORMAT_ARG(dev->devPath, "dev-path"),
|
||||
@@ -108,13 +107,13 @@ void ffPrintPhysicalDisk(FFPhysicalDiskOptions* options)
|
||||
ffTempsAppendNum(dev->temperature, &tempStr, options->tempConfig, &options->moduleArgs);
|
||||
if (dev->type & FF_PHYSICALDISK_TYPE_READWRITE)
|
||||
readOnlyType = "Read-write";
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_PHYSICALDISK_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(buffer, "size"),
|
||||
FF_FORMAT_ARG(dev->name, "name"),
|
||||
FF_FORMAT_ARG(dev->interconnect, "interconnect"),
|
||||
FF_FORMAT_ARG(physicalType, "type"),
|
||||
FF_FORMAT_ARG(dev->devPath, "dev-path"),
|
||||
FF_FORMAT_ARG(dev->serial, "serial"),
|
||||
FF_FORMAT_ARG(physicalType, "physical-type"),
|
||||
FF_FORMAT_ARG(removableType, "removable-type"),
|
||||
FF_FORMAT_ARG(readOnlyType, "readonly-type"),
|
||||
FF_FORMAT_ARG(dev->revision, "revision"),
|
||||
@@ -250,35 +249,31 @@ void ffGeneratePhysicalDiskJsonResult(FFPhysicalDiskOptions* options, yyjson_mut
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintPhysicalDiskHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PHYSICALDISK_MODULE_NAME, "{1} [{6}, {7}, {8}]", FF_PHYSICALDISK_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Device size (formatted) - ",
|
||||
"Device name",
|
||||
"Device interconnect type",
|
||||
"Device raw file path",
|
||||
"Serial number",
|
||||
"Device kind (SSD or HDD)",
|
||||
"Device kind (Removable or Fixed)",
|
||||
"Device kind (Read-only or Read-write)",
|
||||
"Product revision",
|
||||
"Device temperature (formatted)",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_PHYSICALDISK_MODULE_NAME,
|
||||
.description = "Print physical disk information",
|
||||
.parseCommandOptions = (void*) ffParsePhysicalDiskCommandOptions,
|
||||
.parseJsonObject = (void*) ffParsePhysicalDiskJsonObject,
|
||||
.printModule = (void*) ffPrintPhysicalDisk,
|
||||
.generateJsonResult = (void*) ffGeneratePhysicalDiskJsonResult,
|
||||
.generateJsonConfig = (void*) ffGeneratePhysicalDiskJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Device size (formatted)", "size"},
|
||||
{"Device name", "name"},
|
||||
{"Device interconnect type", "interconnect"},
|
||||
{"Device raw file path", "dev-path"},
|
||||
{"Serial number", "serial"},
|
||||
{"Device kind (SSD or HDD)", "physical-type"},
|
||||
{"Device kind (Removable or Fixed)", "removable-type"},
|
||||
{"Device kind (Read-only or Read-write)", "readonly-type"},
|
||||
{"Product revision", "revision"},
|
||||
{"Device temperature (formatted)", "temperature"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitPhysicalDiskOptions(FFPhysicalDiskOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_PHYSICALDISK_MODULE_NAME,
|
||||
"Print physical disk information",
|
||||
ffParsePhysicalDiskCommandOptions,
|
||||
ffParsePhysicalDiskJsonObject,
|
||||
ffPrintPhysicalDisk,
|
||||
ffGeneratePhysicalDiskJsonResult,
|
||||
ffPrintPhysicalDiskHelpFormat,
|
||||
ffGeneratePhysicalDiskJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffStrbufInit(&options->namePrefix);
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "modules/physicalmemory/physicalmemory.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_PHYSICALMEMORY_NUM_FORMAT_ARGS 11
|
||||
#define FF_PHYSICALMEMORY_DISPLAY_NAME "Physical Memory"
|
||||
|
||||
void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options)
|
||||
@@ -54,7 +53,7 @@ void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PHYSICALMEMORY_DISPLAY_NAME, (uint8_t) i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PHYSICALMEMORY_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PHYSICALMEMORY_DISPLAY_NAME, (uint8_t) i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->size, "bytes"),
|
||||
FF_FORMAT_ARG(prettySize, "size"),
|
||||
FF_FORMAT_ARG(device->maxSpeed, "max-speed"),
|
||||
@@ -154,36 +153,31 @@ void ffGeneratePhysicalMemoryJsonResult(FF_MAYBE_UNUSED FFPhysicalMemoryOptions*
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintPhysicalMemoryHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PHYSICALMEMORY_MODULE_NAME, "{7} {5}-{3}: {2}, running at {4} MT/s", FF_PHYSICALMEMORY_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Size (in bytes) - bytes",
|
||||
"Size formatted - size",
|
||||
"Max speed (in MT/s) - max-speed",
|
||||
"Running speed (in MT/s) - running-speed",
|
||||
"Type (DDR4, DDR5, etc.) - type",
|
||||
"Form factor (SODIMM, DIMM, etc.) - form-factor",
|
||||
"Bank/Device Locator (BANK0/SIMM0, BANK0/SIMM1, etc.) - locator",
|
||||
"Vendor - vendor",
|
||||
"Serial number - serial",
|
||||
"Part number - part-number",
|
||||
"True if ECC enabled - is-ecc-enabled",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_PHYSICALMEMORY_MODULE_NAME,
|
||||
.description = "Print system physical memory devices",
|
||||
.parseCommandOptions = (void*) ffParsePhysicalMemoryCommandOptions,
|
||||
.parseJsonObject = (void*) ffParsePhysicalMemoryJsonObject,
|
||||
.printModule = (void*) ffPrintPhysicalMemory,
|
||||
.generateJsonConfig = (void*) ffGeneratePhysicalMemoryJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Size (in bytes)", "bytes"},
|
||||
{"Size formatted", "size"},
|
||||
{"Max speed (in MT/s)", "max-speed"},
|
||||
{"Running speed (in MT/s)", "running-speed"},
|
||||
{"Type (DDR4, DDR5, etc.)", "type"},
|
||||
{"Form factor (SODIMM, DIMM, etc.)", "form-factor"},
|
||||
{"Bank/Device Locator (BANK0/SIMM0, BANK0/SIMM1, etc.)", "locator"},
|
||||
{"Vendor", "vendor"},
|
||||
{"Serial number", "serial"},
|
||||
{"Part number", "part-number"},
|
||||
{"True if ECC enabled", "is-ecc-enabled"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitPhysicalMemoryOptions(FFPhysicalMemoryOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_PHYSICALMEMORY_MODULE_NAME,
|
||||
"Print system physical memory devices",
|
||||
ffParsePhysicalMemoryCommandOptions,
|
||||
ffParsePhysicalMemoryJsonObject,
|
||||
ffPrintPhysicalMemory,
|
||||
ffGeneratePhysicalMemoryJsonResult,
|
||||
ffPrintPhysicalMemoryHelpFormat,
|
||||
ffGeneratePhysicalMemoryJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+17
-22
@@ -7,7 +7,6 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#define FF_PLAYER_DISPLAY_NAME "Media Player"
|
||||
#define FF_PLAYER_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintPlayer(FFPlayerOptions* options)
|
||||
{
|
||||
@@ -73,7 +72,7 @@ void ffPrintPlayer(FFPlayerOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PLAYER_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PLAYER_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(playerPretty, "player"),
|
||||
FF_FORMAT_ARG(media->player, "name"),
|
||||
FF_FORMAT_ARG(media->playerId, "id"),
|
||||
@@ -133,29 +132,25 @@ void ffGeneratePlayerJsonResult(FF_MAYBE_UNUSED FFMediaOptions* options, yyjson_
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "url", &media->url);
|
||||
}
|
||||
|
||||
void ffPrintPlayerHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PLAYER_MODULE_NAME, "{1}", FF_PLAYER_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Pretty player name - player",
|
||||
"Player name - name",
|
||||
"Player Identifier - id",
|
||||
"URL name - url",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_PLAYER_MODULE_NAME,
|
||||
.description = "Print music player name",
|
||||
.parseCommandOptions = (void*) ffParsePlayerCommandOptions,
|
||||
.parseJsonObject = (void*) ffParsePlayerJsonObject,
|
||||
.printModule = (void*) ffPrintPlayer,
|
||||
.generateJsonResult = (void*) ffGeneratePlayerJsonResult,
|
||||
.generateJsonConfig = (void*) ffGeneratePlayerJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Pretty player name", "player"},
|
||||
{"Player name", "name"},
|
||||
{"Player Identifier", "id"},
|
||||
{"URL name", "url"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitPlayerOptions(FFPlayerOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_PLAYER_MODULE_NAME,
|
||||
"Print music player name",
|
||||
ffParsePlayerCommandOptions,
|
||||
ffParsePlayerJsonObject,
|
||||
ffPrintPlayer,
|
||||
ffGeneratePlayerJsonResult,
|
||||
ffPrintPlayerHelpFormat,
|
||||
ffGeneratePlayerJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_POWERADAPTER_DISPLAY_NAME "Power Adapter"
|
||||
#define FF_POWERADAPTER_NUM_FORMAT_ARGS 6
|
||||
|
||||
void ffPrintPowerAdapter(FFPowerAdapterOptions* options)
|
||||
{
|
||||
@@ -38,7 +37,7 @@ void ffPrintPowerAdapter(FFPowerAdapterOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_POWERADAPTER_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_POWERADAPTER_DISPLAY_NAME, i, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result->watts, "watts"),
|
||||
FF_FORMAT_ARG(result->name, "name"),
|
||||
FF_FORMAT_ARG(result->manufacturer, "manufacturer"),
|
||||
@@ -126,31 +125,27 @@ void ffGeneratePowerAdapterJsonResult(FF_MAYBE_UNUSED FFPowerAdapterOptions* opt
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintPowerAdapterHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_POWERADAPTER_MODULE_NAME, "{1}W", FF_POWERADAPTER_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"PowerAdapter watts - watts",
|
||||
"PowerAdapter name - name",
|
||||
"PowerAdapter manufacturer - manufacturer",
|
||||
"PowerAdapter model - model",
|
||||
"PowerAdapter description - description",
|
||||
"PowerAdapter serial number - serial",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_POWERADAPTER_MODULE_NAME,
|
||||
.description = "Print power adapter name and charging watts",
|
||||
.parseCommandOptions = (void*) ffParsePowerAdapterCommandOptions,
|
||||
.parseJsonObject = (void*) ffParsePowerAdapterJsonObject,
|
||||
.printModule = (void*) ffPrintPowerAdapter,
|
||||
.generateJsonResult = (void*) ffGeneratePowerAdapterJsonResult,
|
||||
.generateJsonConfig = (void*) ffGeneratePowerAdapterJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Power adapter watts", "watts"},
|
||||
{"Power adapter name", "name"},
|
||||
{"Power adapter manufacturer", "manufacturer"},
|
||||
{"Power adapter model", "model"},
|
||||
{"Power adapter description", "description"},
|
||||
{"Power adapter serial number", "serial"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitPowerAdapterOptions(FFPowerAdapterOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_POWERADAPTER_MODULE_NAME,
|
||||
"Print power adapter name and charging watts",
|
||||
ffParsePowerAdapterCommandOptions,
|
||||
ffParsePowerAdapterJsonObject,
|
||||
ffPrintPowerAdapter,
|
||||
ffGeneratePowerAdapterJsonResult,
|
||||
ffPrintPowerAdapterHelpFormat,
|
||||
ffGeneratePowerAdapterJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "modules/processes/processes.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_PROCESSES_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintProcesses(FFProcessesOptions* options)
|
||||
{
|
||||
uint32_t numProcesses = 0;
|
||||
@@ -25,7 +23,7 @@ void ffPrintProcesses(FFProcessesOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PROCESSES_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(numProcesses, "result")
|
||||
}));
|
||||
}
|
||||
@@ -80,26 +78,22 @@ void ffGenerateProcessesJsonResult(FF_MAYBE_UNUSED FFProcessesOptions* options,
|
||||
yyjson_mut_obj_add_uint(doc, module, "result", result);
|
||||
}
|
||||
|
||||
void ffPrintProcessesHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PROCESSES_MODULE_NAME, "{1}", FF_PROCESSES_NUM_FORMAT_ARGS, (const char* []) {
|
||||
"Proecess count - result"
|
||||
});
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_PROCESSES_MODULE_NAME,
|
||||
.description = "Print number of running processes",
|
||||
.parseCommandOptions = (void*) ffParseProcessesCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseProcessesJsonObject,
|
||||
.printModule = (void*) ffPrintProcesses,
|
||||
.generateJsonResult = (void*) ffGenerateProcessesJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateProcessesJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Process count", "result"}
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitProcessesOptions(FFProcessesOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_PROCESSES_MODULE_NAME,
|
||||
"Count running processes",
|
||||
ffParseProcessesCommandOptions,
|
||||
ffParseProcessesJsonObject,
|
||||
ffPrintProcesses,
|
||||
ffGenerateProcessesJsonResult,
|
||||
ffPrintProcessesHelpFormat,
|
||||
ffGenerateProcessesJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_PUBLICIP_DISPLAY_NAME "Public IP"
|
||||
#define FF_PUBLICIP_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintPublicIp(FFPublicIpOptions* options)
|
||||
{
|
||||
@@ -30,7 +29,7 @@ void ffPrintPublicIp(FFPublicIpOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PUBLICIP_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_PUBLICIP_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result.ip, "ip"),
|
||||
FF_FORMAT_ARG(result.location, "location"),
|
||||
}));
|
||||
@@ -141,27 +140,23 @@ void ffGeneratePublicIpJsonResult(FFPublicIpOptions* options, yyjson_mut_doc* do
|
||||
ffStrbufDestroy(&result.location);
|
||||
}
|
||||
|
||||
void ffPrintPublicIpHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PUBLICIP_MODULE_NAME, "{1} ({2})", FF_PUBLICIP_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Public IP address - ip",
|
||||
"Location - location",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_PUBLICIP_MODULE_NAME,
|
||||
.description = "Print your public IP address, etc",
|
||||
.parseCommandOptions = (void*) ffParsePublicIpCommandOptions,
|
||||
.parseJsonObject = (void*) ffParsePublicIpJsonObject,
|
||||
.printModule = (void*) ffPrintPublicIp,
|
||||
.generateJsonResult = (void*) ffGeneratePublicIpJsonResult,
|
||||
.generateJsonConfig = (void*) ffGeneratePublicIpJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Public IP address", "ip"},
|
||||
{"Location", "location"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitPublicIpOptions(FFPublicIpOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_PUBLICIP_MODULE_NAME,
|
||||
"Print your public IP address, etc",
|
||||
ffParsePublicIpCommandOptions,
|
||||
ffParsePublicIpJsonObject,
|
||||
ffPrintPublicIp,
|
||||
ffGeneratePublicIpJsonResult,
|
||||
ffPrintPublicIpHelpFormat,
|
||||
ffGeneratePublicIpJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffStrbufInit(&options->url);
|
||||
|
||||
@@ -178,19 +178,23 @@ void ffGenerateSeparatorJsonConfig(FFSeparatorOptions* options, yyjson_mut_doc*
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "string", &options->string);
|
||||
}
|
||||
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_SEPARATOR_MODULE_NAME,
|
||||
.description = "Print a separator line",
|
||||
.parseCommandOptions = (void*) ffParseSeparatorCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseSeparatorJsonObject,
|
||||
.printModule = (void*) ffPrintSeparator,
|
||||
.generateJsonConfig = (void*) ffGenerateSeparatorJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Separator string", "string"},
|
||||
{"Output color", "outputColor"},
|
||||
{"Length", "length"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitSeparatorOptions(FFSeparatorOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_SEPARATOR_MODULE_NAME,
|
||||
"Print a separator line",
|
||||
ffParseSeparatorCommandOptions,
|
||||
ffParseSeparatorJsonObject,
|
||||
ffPrintSeparator,
|
||||
NULL,
|
||||
NULL,
|
||||
ffGenerateSeparatorJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffStrbufInitStatic(&options->string, "-");
|
||||
ffStrbufInit(&options->outputColor);
|
||||
options->length = 0;
|
||||
|
||||
+21
-27
@@ -4,8 +4,6 @@
|
||||
#include "modules/shell/shell.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_SHELL_NUM_FORMAT_ARGS 8
|
||||
|
||||
void ffPrintShell(FFShellOptions* options)
|
||||
{
|
||||
const FFShellResult* result = ffDetectShell();
|
||||
@@ -31,7 +29,7 @@ void ffPrintShell(FFShellOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_SHELL_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_SHELL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result->processName, "process-name"),
|
||||
FF_FORMAT_ARG(result->exe, "exe"),
|
||||
FF_FORMAT_ARG(result->exeName, "exe-name"),
|
||||
@@ -104,33 +102,29 @@ void ffGenerateShellJsonResult(FF_MAYBE_UNUSED FFShellOptions* options, yyjson_m
|
||||
yyjson_mut_obj_add_null(doc, obj, "tty");
|
||||
}
|
||||
|
||||
void ffPrintShellHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_SHELL_MODULE_NAME, "{3} {4}", FF_SHELL_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Shell process name - process-name",
|
||||
"The first argument of the command line when running the shell - exe",
|
||||
"Shell base name of arg0 - exe-name",
|
||||
"Shell version - version",
|
||||
"Shell pid - pid",
|
||||
"Shell pretty name - pretty-name",
|
||||
"Shell full exe path - exe-path",
|
||||
"Shell tty used - tty",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_SHELL_MODULE_NAME,
|
||||
.description = "Print current shell name and version",
|
||||
.parseCommandOptions = (void*) ffParseShellCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseShellJsonObject,
|
||||
.printModule = (void*) ffPrintShell,
|
||||
.generateJsonResult = (void*) ffGenerateShellJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateShellJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Shell process name", "process-name"},
|
||||
{"The first argument of the command line when running the shell", "exe"},
|
||||
{"Shell base name of arg0", "exe-name"},
|
||||
{"Shell version", "version"},
|
||||
{"Shell pid", "pid"},
|
||||
{"Shell pretty name", "pretty-name"},
|
||||
{"Shell full exe path", "exe-path"},
|
||||
{"Shell tty used", "tty"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitShellOptions(FFShellOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_SHELL_MODULE_NAME,
|
||||
"Print current shell name and version",
|
||||
ffParseShellCommandOptions,
|
||||
ffParseShellJsonObject,
|
||||
ffPrintShell,
|
||||
ffGenerateShellJsonResult,
|
||||
ffPrintShellHelpFormat,
|
||||
ffGenerateShellJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+18
-24
@@ -5,8 +5,6 @@
|
||||
#include "modules/sound/sound.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_SOUND_NUM_FORMAT_ARGS 5
|
||||
|
||||
static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, uint8_t index)
|
||||
{
|
||||
FFPercentageTypeFlags percentType = options->percent.type == 0 ? instance.config.display.percentType : options->percent.type;
|
||||
@@ -54,7 +52,7 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&percentageBar, device->volume, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_SOUND_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(device->main, "is-main"),
|
||||
FF_FORMAT_ARG(device->name, "name"),
|
||||
FF_FORMAT_ARG(percentageNum, "volume-percentage"),
|
||||
@@ -229,30 +227,26 @@ void ffGenerateSoundJsonResult(FF_MAYBE_UNUSED FFSoundOptions* options, yyjson_m
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintSoundHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_SOUND_MODULE_NAME, "{2} ({3}%)", FF_SOUND_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Is main sound device - is-main",
|
||||
"Device name - name",
|
||||
"Volume (in percentage num) - volume-percentage",
|
||||
"Identifier - identifier",
|
||||
"Volume (in percentage bar) - volume-percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_SOUND_MODULE_NAME,
|
||||
.description = "Print sound devices, volume, etc",
|
||||
.parseCommandOptions = (void*) ffParseSoundCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseSoundJsonObject,
|
||||
.printModule = (void*) ffPrintSound,
|
||||
.generateJsonResult = (void*) ffGenerateSoundJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateSoundJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Is main sound device", "is-main"},
|
||||
{"Device name", "name"},
|
||||
{"Volume (in percentage num)", "volume-percentage"},
|
||||
{"Identifier", "identifier"},
|
||||
{"Volume (in percentage bar)", "volume-percentage-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitSoundOptions(FFSoundOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_SOUND_MODULE_NAME,
|
||||
"Print sound devices, volume, etc",
|
||||
ffParseSoundCommandOptions,
|
||||
ffParseSoundJsonObject,
|
||||
ffPrintSound,
|
||||
ffGenerateSoundJsonResult,
|
||||
ffPrintSoundHelpFormat,
|
||||
ffGenerateSoundJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->soundType = FF_SOUND_TYPE_MAIN;
|
||||
|
||||
+17
-23
@@ -6,8 +6,6 @@
|
||||
#include "modules/swap/swap.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_SWAP_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintSwap(FFSwapOptions* options)
|
||||
{
|
||||
FFSwapResult storage = {};
|
||||
@@ -73,7 +71,7 @@ void ffPrintSwap(FFSwapOptions* options)
|
||||
FF_STRBUF_AUTO_DESTROY percentageBar = ffStrbufCreate();
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&percentageBar, percentage, options->percent, &options->moduleArgs);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_SWAP_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_SWAP_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(usedPretty, "used"),
|
||||
FF_FORMAT_ARG(totalPretty, "total"),
|
||||
FF_FORMAT_ARG(percentageNum, "percentage"),
|
||||
@@ -141,29 +139,25 @@ void ffGenerateSwapJsonResult(FF_MAYBE_UNUSED FFSwapOptions* options, yyjson_mut
|
||||
yyjson_mut_obj_add_uint(doc, obj, "used", storage.bytesUsed);
|
||||
}
|
||||
|
||||
void ffPrintSwapHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_SWAP_MODULE_NAME, "{1} / {2} ({3})", FF_SWAP_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Used size - used",
|
||||
"Total size - total",
|
||||
"Percentage used (num) - percentage",
|
||||
"Percentage used (bar) - percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_SWAP_MODULE_NAME,
|
||||
.description = "Print swap (paging file) space usage",
|
||||
.parseCommandOptions = (void*) ffParseSwapCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseSwapJsonObject,
|
||||
.printModule = (void*) ffPrintSwap,
|
||||
.generateJsonResult = (void*) ffGenerateSwapJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateSwapJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Used size", "used"},
|
||||
{"Total size", "total"},
|
||||
{"Percentage used (num)", "percentage"},
|
||||
{"Percentage used (bar)", "percentage-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitSwapOptions(FFSwapOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_SWAP_MODULE_NAME,
|
||||
"Print swap (paging file) space usage",
|
||||
ffParseSwapCommandOptions,
|
||||
ffParseSwapJsonObject,
|
||||
ffPrintSwap,
|
||||
ffGenerateSwapJsonResult,
|
||||
ffPrintSwapHelpFormat,
|
||||
ffGenerateSwapJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 80, 0 };
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
#include "modules/terminal/terminal.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define FF_TERMINAL_NUM_FORMAT_ARGS 8
|
||||
|
||||
void ffPrintTerminal(FFTerminalOptions* options)
|
||||
{
|
||||
const FFTerminalResult* result = ffDetectTerminal();
|
||||
@@ -29,7 +25,7 @@ void ffPrintTerminal(FFTerminalOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINAL_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINAL_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result->processName, "process-name"),
|
||||
FF_FORMAT_ARG(result->exe, "exe"),
|
||||
FF_FORMAT_ARG(result->exeName, "exe-name"),
|
||||
@@ -99,33 +95,29 @@ void ffGenerateTerminalJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options, yy
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "tty", &result->tty);
|
||||
}
|
||||
|
||||
void ffPrintTerminalHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINAL_MODULE_NAME, "{5} {6}", FF_TERMINAL_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Terminal process name - process-name",
|
||||
"The first argument of the command line when running the terminal - exe",
|
||||
"Terminal base name of arg0 - exe-name",
|
||||
"Terminal pid - pid",
|
||||
"Terminal pretty name - pretty-name",
|
||||
"Terminal version - version",
|
||||
"Terminal full exe path - exe-path",
|
||||
"Terminal tty / pts used - tty",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_TERMINAL_MODULE_NAME,
|
||||
.description = "Print current terminal name and version",
|
||||
.parseCommandOptions = (void*) ffParseTerminalCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseTerminalJsonObject,
|
||||
.printModule = (void*) ffPrintTerminal,
|
||||
.generateJsonResult = (void*) ffGenerateTerminalJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateTerminalJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Terminal process name", "process-name"},
|
||||
{"The first argument of the command line when running the terminal", "exe"},
|
||||
{"Terminal base name of arg0", "exe-name"},
|
||||
{"Terminal pid", "pid"},
|
||||
{"Terminal pretty name", "pretty-name"},
|
||||
{"Terminal version", "version"},
|
||||
{"Terminal full exe path", "exe-path"},
|
||||
{"Terminal tty / pts used", "tty"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitTerminalOptions(FFTerminalOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_TERMINAL_MODULE_NAME,
|
||||
"Print current terminal name and version",
|
||||
ffParseTerminalCommandOptions,
|
||||
ffParseTerminalJsonObject,
|
||||
ffPrintTerminal,
|
||||
ffGenerateTerminalJsonResult,
|
||||
ffPrintTerminalHelpFormat,
|
||||
ffGenerateTerminalJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_TERMINALFONT_DISPLAY_NAME "Terminal Font"
|
||||
#define FF_TERMINALFONT_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintTerminalFont(FFTerminalFontOptions* options)
|
||||
{
|
||||
@@ -33,7 +32,7 @@ void ffPrintTerminalFont(FFTerminalFontOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINALFONT_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALFONT_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(terminalFont.font.pretty, "combined"),
|
||||
FF_FORMAT_ARG(terminalFont.font.name, "name"),
|
||||
FF_FORMAT_ARG(terminalFont.font.size, "size"),
|
||||
@@ -121,29 +120,25 @@ void ffGenerateTerminalFontJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options
|
||||
ffFontDestroy(&result.fallback);
|
||||
}
|
||||
|
||||
void ffPrintTerminalFontHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINALFONT_MODULE_NAME, "{1}", FF_TERMINALFONT_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Terminal font combined - combined",
|
||||
"Terminal font name - name",
|
||||
"Terminal font size - size",
|
||||
"Terminal font styles - styles",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_TERMINALFONT_MODULE_NAME,
|
||||
.description = "Print font name and size used by current terminal",
|
||||
.parseCommandOptions = (void*) ffParseTerminalFontCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseTerminalFontJsonObject,
|
||||
.printModule = (void*) ffPrintTerminalFont,
|
||||
.generateJsonResult = (void*) ffGenerateTerminalFontJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateTerminalFontJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Terminal font combined", "combined"},
|
||||
{"Terminal font name", "name"},
|
||||
{"Terminal font size", "size"},
|
||||
{"Terminal font styles", "styles"},
|
||||
})),
|
||||
};
|
||||
|
||||
void ffInitTerminalFontOptions(FFTerminalFontOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_TERMINALFONT_MODULE_NAME,
|
||||
"Print font name and size used by current terminal",
|
||||
ffParseTerminalFontCommandOptions,
|
||||
ffParseTerminalFontJsonObject,
|
||||
ffPrintTerminalFont,
|
||||
ffGenerateTerminalFontJsonResult,
|
||||
ffPrintTerminalFontHelpFormat,
|
||||
ffGenerateTerminalFontJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_TERMINALSIZE_DISPLAY_NAME "Terminal Size"
|
||||
#define FF_TERMINALSIZE_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintTerminalSize(FFTerminalSizeOptions* options)
|
||||
{
|
||||
@@ -29,7 +28,7 @@ void ffPrintTerminalSize(FFTerminalSizeOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINALSIZE_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result.rows, "rows"),
|
||||
FF_FORMAT_ARG(result.columns, "columns"),
|
||||
FF_FORMAT_ARG(result.width, "width"),
|
||||
@@ -91,29 +90,25 @@ void ffGenerateTerminalSizeJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options
|
||||
yyjson_mut_obj_add_uint(doc, obj, "height", result.height);
|
||||
}
|
||||
|
||||
void ffPrintTerminalSizeHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINALSIZE_MODULE_NAME, "{1} columns x {2} rows ({3}px x {4}px)", FF_TERMINALSIZE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Terminal rows - rows",
|
||||
"Terminal columns - columns",
|
||||
"Terminal width (in pixels) - width",
|
||||
"Terminal height (in pixels) - height",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_TERMINALSIZE_MODULE_NAME,
|
||||
.description = "Print current terminal size",
|
||||
.parseCommandOptions = (void*) ffParseTerminalSizeCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseTerminalSizeJsonObject,
|
||||
.printModule = (void*) ffPrintTerminalSize,
|
||||
.generateJsonResult = (void*) ffGenerateTerminalSizeJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateTerminalSizeJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Terminal rows", "rows"},
|
||||
{"Terminal columns", "columns"},
|
||||
{"Terminal width (in pixels)", "width"},
|
||||
{"Terminal height (in pixels)", "height"},
|
||||
})),
|
||||
};
|
||||
|
||||
void ffInitTerminalSizeOptions(FFTerminalSizeOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_TERMINALSIZE_MODULE_NAME,
|
||||
"Print current terminal size",
|
||||
ffParseTerminalSizeCommandOptions,
|
||||
ffParseTerminalSizeJsonObject,
|
||||
ffPrintTerminalSize,
|
||||
ffGenerateTerminalSizeJsonResult,
|
||||
ffPrintTerminalSizeHelpFormat,
|
||||
ffGenerateTerminalSizeJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#define FF_TERMINALTHEME_DISPLAY_NAME "Terminal Theme"
|
||||
#define FF_TERMINALTHEME_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintTerminalTheme(FFTerminalThemeOptions* options)
|
||||
{
|
||||
@@ -34,7 +33,7 @@ void ffPrintTerminalTheme(FFTerminalThemeOptions* options)
|
||||
const char* bgType = result.bg.dark ? "Dark" : "Light";
|
||||
snprintf(fg, ARRAY_SIZE(fg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.fg.r, result.fg.g, result.fg.b);
|
||||
snprintf(bg, ARRAY_SIZE(bg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.bg.r, result.bg.g, result.bg.b);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TERMINALTHEME_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(fg, "fg-color"),
|
||||
FF_FORMAT_ARG(fgType, "fg-type"),
|
||||
FF_FORMAT_ARG(bg, "bg-color"),
|
||||
@@ -104,29 +103,25 @@ void ffGenerateTerminalThemeJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* option
|
||||
yyjson_mut_obj_add_bool(doc, bg, "dark", result.bg.dark);
|
||||
}
|
||||
|
||||
void ffPrintTerminalThemeHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TERMINALTHEME_MODULE_NAME, "{1} (FG) {3} (BG) [{4}]", FF_TERMINALTHEME_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Terminal foreground color - fg-color",
|
||||
"Terminal foreground type (Dark / Light) - fg-type",
|
||||
"Terminal background color - bg-color",
|
||||
"Terminal background type (Dark / Light) - bg-type",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_TERMINALTHEME_MODULE_NAME,
|
||||
.description = "Print current terminal theme (foreground and background colors)",
|
||||
.parseCommandOptions = (void*) ffParseTerminalThemeCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseTerminalThemeJsonObject,
|
||||
.printModule = (void*) ffPrintTerminalTheme,
|
||||
.generateJsonResult = (void*) ffGenerateTerminalThemeJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateTerminalThemeJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Terminal foreground color", "fg-color"},
|
||||
{"Terminal foreground type (Dark / Light)", "fg-type"},
|
||||
{"Terminal background color", "bg-color"},
|
||||
{"Terminal background type (Dark / Light)", "bg-type"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitTerminalThemeOptions(FFTerminalThemeOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_TERMINALTHEME_MODULE_NAME,
|
||||
"Print current terminal theme (foreground and background colors)",
|
||||
ffParseTerminalThemeCommandOptions,
|
||||
ffParseTerminalThemeJsonObject,
|
||||
ffPrintTerminalTheme,
|
||||
ffGenerateTerminalThemeJsonResult,
|
||||
ffPrintTerminalThemeHelpFormat,
|
||||
ffGenerateTerminalThemeJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+15
-21
@@ -4,8 +4,6 @@
|
||||
#include "modules/theme/theme.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_THEME_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintTheme(FFThemeOptions* options)
|
||||
{
|
||||
FFThemeResult result = {
|
||||
@@ -35,7 +33,7 @@ void ffPrintTheme(FFThemeOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_THEME_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_THEME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result.theme1, "theme1"),
|
||||
FF_FORMAT_ARG(result.theme2, "theme2"),
|
||||
}));
|
||||
@@ -102,27 +100,23 @@ void ffGenerateThemeJsonResult(FF_MAYBE_UNUSED FFThemeOptions* options, yyjson_m
|
||||
ffStrbufDestroy(&result.theme2);
|
||||
}
|
||||
|
||||
void ffPrintThemeHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_THEME_MODULE_NAME, "{1}, {2}", FF_THEME_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Theme part 1 - theme1",
|
||||
"Theme part 2 - theme2",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_THEME_MODULE_NAME,
|
||||
.description = "Print current theme of desktop environment",
|
||||
.parseCommandOptions = (void*) ffParseThemeCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseThemeJsonObject,
|
||||
.printModule = (void*) ffPrintTheme,
|
||||
.generateJsonResult = (void*) ffGenerateThemeJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateThemeJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Theme part 1", "theme1"},
|
||||
{"Theme part 2", "theme2"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitThemeOptions(FFThemeOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_THEME_MODULE_NAME,
|
||||
"Print current theme of desktop environment",
|
||||
ffParseThemeCommandOptions,
|
||||
ffParseThemeJsonObject,
|
||||
ffPrintTheme,
|
||||
ffGenerateThemeJsonResult,
|
||||
ffPrintThemeHelpFormat,
|
||||
ffGenerateThemeJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+21
-27
@@ -4,8 +4,6 @@
|
||||
#include "util/textModifier.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_TITLE_NUM_FORMAT_ARGS 8
|
||||
|
||||
static void appendText(FFstrbuf* output, const FFstrbuf* text, const FFstrbuf* color)
|
||||
{
|
||||
if (!instance.config.display.pipe)
|
||||
@@ -56,7 +54,7 @@ void ffPrintTitle(FFTitleOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TITLE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TITLE_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TITLE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(instance.state.platform.userName, "user-name"),
|
||||
FF_FORMAT_ARG(hostName, "host-name"),
|
||||
FF_FORMAT_ARG(instance.state.platform.homeDir, "home-dir"),
|
||||
@@ -178,33 +176,29 @@ void ffGenerateTitleJsonResult(FF_MAYBE_UNUSED FFTitleOptions* options, yyjson_m
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "userShell", &instance.state.platform.userShell);
|
||||
}
|
||||
|
||||
void ffPrintTitleHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TITLE_MODULE_NAME, "{6}{7}{8}", FF_TITLE_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"User name - user-name",
|
||||
"Host name - host-name",
|
||||
"Home directory - home-dir",
|
||||
"Executable path of current process - exe-path",
|
||||
"User's default shell - user-shell",
|
||||
"User name (colored) - user-name-colored",
|
||||
"@ symbol (colored) - at-symbol-colored",
|
||||
"Host name (colored) - host-name-colored",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_TITLE_MODULE_NAME,
|
||||
.description = "Print title, which contains your user name, hostname",
|
||||
.parseCommandOptions = (void*) ffParseTitleCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseTitleJsonObject,
|
||||
.printModule = (void*) ffPrintTitle,
|
||||
.generateJsonResult = (void*) ffGenerateTitleJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateTitleJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"User name", "user-name"},
|
||||
{"Host name", "host-name"},
|
||||
{"Home directory", "home-dir"},
|
||||
{"Executable path of current process", "exe-path"},
|
||||
{"User's default shell", "user-shell"},
|
||||
{"User name (colored)", "user-name-colored"},
|
||||
{"@ symbol (colored)", "at-symbol-colored"},
|
||||
{"Host name (colored)", "host-name-colored"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitTitleOptions(FFTitleOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_TITLE_MODULE_NAME,
|
||||
"Print title, which contains your user name, hostname",
|
||||
ffParseTitleCommandOptions,
|
||||
ffParseTitleJsonObject,
|
||||
ffPrintTitle,
|
||||
ffGenerateTitleJsonResult,
|
||||
ffPrintTitleHelpFormat,
|
||||
ffGenerateTitleJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
ffStrbufSetStatic(&options->moduleArgs.key, " ");
|
||||
|
||||
|
||||
+15
-21
@@ -4,8 +4,6 @@
|
||||
#include "modules/tpm/tpm.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_TPM_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintTPM(FFTPMOptions* options)
|
||||
{
|
||||
FFTPMResult result = {
|
||||
@@ -30,7 +28,7 @@ void ffPrintTPM(FFTPMOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TPM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_TPM_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TPM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result.version, "version"),
|
||||
FF_FORMAT_ARG(result.description, "description"),
|
||||
}));
|
||||
@@ -97,27 +95,23 @@ void ffGenerateTPMJsonResult(FF_MAYBE_UNUSED FFTerminalOptions* options, yyjson_
|
||||
ffStrbufDestroy(&result.description);
|
||||
}
|
||||
|
||||
void ffPrintTPMHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_TPM_MODULE_NAME, "{2}", FF_TPM_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"TPM device version - version",
|
||||
"TPM general description - description",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_TPM_MODULE_NAME,
|
||||
.description = "Print info of Trusted Platform Module (TPM) Security Device",
|
||||
.parseCommandOptions = (void*) ffParseTPMCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseTPMJsonObject,
|
||||
.printModule = (void*) ffPrintTPM,
|
||||
.generateJsonResult = (void*) ffGenerateTPMJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateTPMJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"TPM device version", "version"},
|
||||
{"TPM general description", "description"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitTPMOptions(FFTPMOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_TPM_MODULE_NAME,
|
||||
"Print info of Trusted Platform Module (TPM) Security Device",
|
||||
ffParseTPMCommandOptions,
|
||||
ffParseTPMJsonObject,
|
||||
ffPrintTPM,
|
||||
ffGenerateTPMJsonResult,
|
||||
ffPrintTPMHelpFormat,
|
||||
ffGenerateTPMJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+19
-25
@@ -5,8 +5,6 @@
|
||||
#include "modules/uptime/uptime.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_UPTIME_NUM_FORMAT_ARGS 6
|
||||
|
||||
void ffPrintUptime(FFUptimeOptions* options)
|
||||
{
|
||||
FFUptimeResult result;
|
||||
@@ -41,7 +39,7 @@ void ffPrintUptime(FFUptimeOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_UPTIME_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_UPTIME_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(days, "days"),
|
||||
FF_FORMAT_ARG(hours, "hours"),
|
||||
FF_FORMAT_ARG(minutes, "minutes"),
|
||||
@@ -103,31 +101,27 @@ void ffGenerateUptimeJsonResult(FF_MAYBE_UNUSED FFUptimeOptions* options, yyjson
|
||||
yyjson_mut_obj_add_strcpy(doc, obj, "bootTime", ffTimeToFullStr(result.bootTime));
|
||||
}
|
||||
|
||||
void ffPrintUptimeHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_UPTIME_MODULE_NAME, "{1} days {2} hours {3} mins", FF_UPTIME_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Days - days",
|
||||
"Hours - hours",
|
||||
"Minutes - minutes",
|
||||
"Seconds - seconds",
|
||||
"Milliseconds - milliseconds",
|
||||
"Boot time in local timezone - boot-time",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_UPTIME_MODULE_NAME,
|
||||
.description = "Print how long system has been running",
|
||||
.parseCommandOptions = (void*) ffParseUptimeCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseUptimeJsonObject,
|
||||
.printModule = (void*) ffPrintUptime,
|
||||
.generateJsonResult = (void*) ffGenerateUptimeJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateUptimeJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Days", "days"},
|
||||
{"Hours", "hours"},
|
||||
{"Minutes", "minutes"},
|
||||
{"Seconds", "seconds"},
|
||||
{"Milliseconds", "milliseconds"},
|
||||
{"Boot time in local timezone", "boot-time"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitUptimeOptions(FFUptimeOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_UPTIME_MODULE_NAME,
|
||||
"Print how long system has been running",
|
||||
ffParseUptimeCommandOptions,
|
||||
ffParseUptimeJsonObject,
|
||||
ffPrintUptime,
|
||||
ffGenerateUptimeJsonResult,
|
||||
ffPrintUptimeHelpFormat,
|
||||
ffGenerateUptimeJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+18
-24
@@ -7,8 +7,6 @@
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wformat" // warning: unknown conversion type character 'F' in format
|
||||
|
||||
#define FF_USERS_NUM_FORMAT_ARGS 5
|
||||
|
||||
void ffPrintUsers(FFUsersOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY users = ffListCreate(sizeof(FFUserResult));
|
||||
@@ -68,7 +66,7 @@ void ffPrintUsers(FFUsersOptions* options)
|
||||
{
|
||||
FFUserResult* user = FF_LIST_GET(FFUserResult, users, i);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_USERS_MODULE_NAME, users.length == 1 ? 0 : (uint8_t) (i + 1), &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_USERS_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_USERS_MODULE_NAME, users.length == 1 ? 0 : (uint8_t) (i + 1), &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(user->name, "name"),
|
||||
FF_FORMAT_ARG(user->hostName, "host-name"),
|
||||
FF_FORMAT_ARG(user->sessionName, "session-name"),
|
||||
@@ -188,30 +186,26 @@ void ffGenerateUsersJsonResult(FFUsersOptions* options, yyjson_mut_doc* doc, yyj
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintUsersHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_USERS_MODULE_NAME, "{1}@{2} - login time {5}", FF_USERS_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"User name - name",
|
||||
"Host name - host-name",
|
||||
"Session name - session",
|
||||
"Client IP - client-ip",
|
||||
"Login Time in local timezone - login-time",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_USERS_MODULE_NAME,
|
||||
.description = "Print users currently logged in",
|
||||
.parseCommandOptions = (void*) ffParseUsersCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseUsersJsonObject,
|
||||
.printModule = (void*) ffPrintUsers,
|
||||
.generateJsonResult = (void*) ffGenerateUsersJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateUsersJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"User name", "name"},
|
||||
{"Host name", "host-name"},
|
||||
{"Session name", "session"},
|
||||
{"Client IP", "client-ip"},
|
||||
{"Login Time in local timezone", "login-time"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitUsersOptions(FFUsersOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_USERS_MODULE_NAME,
|
||||
"Print users currently logged in",
|
||||
ffParseUsersCommandOptions,
|
||||
ffParseUsersJsonObject,
|
||||
ffPrintUsers,
|
||||
ffGenerateUsersJsonResult,
|
||||
ffPrintUsersHelpFormat,
|
||||
ffGenerateUsersJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->compact = false;
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "modules/version/version.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_VERSION_NUM_FORMAT_ARGS 10
|
||||
|
||||
void ffPrintVersion(FFVersionOptions* options)
|
||||
{
|
||||
FFVersionResult* result = &ffVersionResult;
|
||||
@@ -31,7 +29,7 @@ void ffPrintVersion(FFVersionOptions* options)
|
||||
}
|
||||
|
||||
const char* buildType = result->debugMode ? "debug" : "release";
|
||||
FF_PRINT_FORMAT_CHECKED(FF_VERSION_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_VERSION_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_VERSION_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result->projectName, "project-name"),
|
||||
FF_FORMAT_ARG(result->version, "version"),
|
||||
FF_FORMAT_ARG(result->versionTweak, "version-tweak"),
|
||||
@@ -113,35 +111,31 @@ void ffGenerateVersionJsonResult(FF_MAYBE_UNUSED FFVersionOptions* options, yyjs
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintVersionHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_VERSION_MODULE_NAME, "{1} {2}{3} ({5})", FF_VERSION_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Project name - name",
|
||||
"Version - version",
|
||||
"Version tweak - version-tweak",
|
||||
"Build type (debug or release) - build-type",
|
||||
"System name - sysname",
|
||||
"Architecture - arch",
|
||||
"CMake build type when compiling (Debug, Release, RelWithDebInfo, MinSizeRel) - cmake-built-type",
|
||||
"Date time when compiling - compile-time",
|
||||
"Compiler used when compiling - compiler",
|
||||
"Libc used when compiling - libc",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_VERSION_MODULE_NAME,
|
||||
.description = "Print Fastfetch version",
|
||||
.parseCommandOptions = (void*) ffParseVersionCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseVersionJsonObject,
|
||||
.printModule = (void*) ffPrintVersion,
|
||||
.generateJsonResult = (void*) ffGenerateVersionJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateVersionJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Project name", "name"},
|
||||
{"Version", "version"},
|
||||
{"Version tweak", "version-tweak"},
|
||||
{"Build type (debug or release)", "build-type"},
|
||||
{"System name", "sysname"},
|
||||
{"Architecture", "arch"},
|
||||
{"CMake build type when compiling (Debug, Release, RelWithDebInfo, MinSizeRel)", "cmake-built-type"},
|
||||
{"Date time when compiling", "compile-time"},
|
||||
{"Compiler used when compiling", "compiler"},
|
||||
{"Libc used when compiling", "libc"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitVersionOptions(FFVersionOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_VERSION_MODULE_NAME,
|
||||
"Print Fastfetch version",
|
||||
ffParseVersionCommandOptions,
|
||||
ffParseVersionJsonObject,
|
||||
ffPrintVersion,
|
||||
ffGenerateVersionJsonResult,
|
||||
ffPrintVersionHelpFormat,
|
||||
ffGenerateVersionJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+17
-23
@@ -5,8 +5,6 @@
|
||||
#include "modules/vulkan/vulkan.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_VULKAN_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintVulkan(FFVulkanOptions* options)
|
||||
{
|
||||
const FFVulkanResult* vulkan = ffDetectVulkan();
|
||||
@@ -43,7 +41,7 @@ void ffPrintVulkan(FFVulkanOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_VULKAN_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_VULKAN_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(vulkan->driver, "driver"),
|
||||
FF_FORMAT_ARG(vulkan->apiVersion, "api-version"),
|
||||
FF_FORMAT_ARG(vulkan->conformanceVersion, "conformance-version"),
|
||||
@@ -144,29 +142,25 @@ void ffGenerateVulkanJsonResult(FF_MAYBE_UNUSED FFVulkanOptions* options, yyjson
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintVulkanHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_VULKAN_MODULE_NAME, "{2} - {1}", FF_VULKAN_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Driver name - driver",
|
||||
"API version - api-version",
|
||||
"Conformance version - conformance-version",
|
||||
"Instance version - instance-version",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_VULKAN_MODULE_NAME,
|
||||
.description = "Print highest Vulkan version supported by the GPU",
|
||||
.parseCommandOptions = (void*) ffParseVulkanCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseVulkanJsonObject,
|
||||
.printModule = (void*) ffPrintVulkan,
|
||||
.generateJsonResult = (void*) ffGenerateVulkanJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateVulkanJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Driver name", "driver"},
|
||||
{"API version", "api-version"},
|
||||
{"Conformance version", "conformance-version"},
|
||||
{"Instance version", "instance-version"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitVulkanOptions(FFVulkanOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_VULKAN_MODULE_NAME,
|
||||
"Print highest Vulkan version supported by the GPU",
|
||||
ffParseVulkanCommandOptions,
|
||||
ffParseVulkanJsonObject,
|
||||
ffPrintVulkan,
|
||||
ffGenerateVulkanJsonResult,
|
||||
ffPrintVulkanHelpFormat,
|
||||
ffGenerateVulkanJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "modules/wallpaper/wallpaper.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_WALLPAPER_NUM_FORMAT_ARGS 2
|
||||
|
||||
void ffPrintWallpaper(FFWallpaperOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY fullpath = ffStrbufCreate();
|
||||
@@ -35,7 +33,7 @@ void ffPrintWallpaper(FFWallpaperOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WALLPAPER_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_WALLPAPER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(filename, "file-name"),
|
||||
FF_FORMAT_ARG(fullpath, "full-path"),
|
||||
}));
|
||||
@@ -89,27 +87,23 @@ void ffGenerateWallpaperJsonResult(FF_MAYBE_UNUSED FFWallpaperOptions* options,
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "result", &fullpath);
|
||||
}
|
||||
|
||||
void ffPrintWallpaperHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WALLPAPER_MODULE_NAME, "{1}", FF_WALLPAPER_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"File name - file-name",
|
||||
"Full path - full-path",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_WALLPAPER_MODULE_NAME,
|
||||
.description = "Print image file path of current wallpaper",
|
||||
.parseCommandOptions = (void*) ffParseWallpaperCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseWallpaperJsonObject,
|
||||
.printModule = (void*) ffPrintWallpaper,
|
||||
.generateJsonResult = (void*) ffGenerateWallpaperJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateWallpaperJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"File name", "file-name"},
|
||||
{"Full path", "full-path"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitWallpaperOptions(FFWallpaperOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_WALLPAPER_MODULE_NAME,
|
||||
"Print image file path of current wallpaper",
|
||||
ffParseWallpaperCommandOptions,
|
||||
ffParseWallpaperJsonObject,
|
||||
ffPrintWallpaper,
|
||||
ffGenerateWallpaperJsonResult,
|
||||
ffPrintWallpaperHelpFormat,
|
||||
ffGenerateWallpaperJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "modules/weather/weather.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_WEATHER_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintWeather(FFWeatherOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate();
|
||||
@@ -25,7 +23,7 @@ void ffPrintWeather(FFWeatherOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WEATHER_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_WEATHER_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result, "result"),
|
||||
}));
|
||||
}
|
||||
@@ -125,26 +123,22 @@ void ffGenerateWeatherJsonResult(FFWeatherOptions* options, yyjson_mut_doc* doc,
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "result", &result);
|
||||
}
|
||||
|
||||
void ffPrintWeatherHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WEATHER_MODULE_NAME, "{1}", FF_WEATHER_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Weather result - result",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_WEATHER_MODULE_NAME,
|
||||
.description = "Print weather information",
|
||||
.parseCommandOptions = (void*) ffParseWeatherCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseWeatherJsonObject,
|
||||
.printModule = (void*) ffPrintWeather,
|
||||
.generateJsonResult = (void*) ffGenerateWeatherJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateWeatherJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Weather result", "result"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitWeatherOptions(FFWeatherOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_WEATHER_MODULE_NAME,
|
||||
"Print weather information",
|
||||
ffParseWeatherCommandOptions,
|
||||
ffParseWeatherJsonObject,
|
||||
ffPrintWeather,
|
||||
ffGenerateWeatherJsonResult,
|
||||
ffPrintWeatherHelpFormat,
|
||||
ffGenerateWeatherJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffStrbufInit(&options->location);
|
||||
|
||||
+26
-32
@@ -4,8 +4,6 @@
|
||||
#include "modules/wifi/wifi.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_WIFI_NUM_FORMAT_ARGS 13
|
||||
|
||||
void ffPrintWifi(FFWifiOptions* options)
|
||||
{
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFWifiResult));
|
||||
@@ -108,7 +106,7 @@ void ffPrintWifi(FFWifiOptions* options)
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&percentBar, item->conn.signalQuality, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WIFI_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_WIFI_MODULE_NAME, moduleIndex, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(item->inf.description, "inf-desc"),
|
||||
FF_FORMAT_ARG(item->inf.status, "inf-status"),
|
||||
FF_FORMAT_ARG(item->conn.status, "status"),
|
||||
@@ -222,38 +220,34 @@ void ffGenerateWifiJsonResult(FF_MAYBE_UNUSED FFWifiOptions* options, yyjson_mut
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintWifiHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WIFI_MODULE_NAME, "{4} - {10}", FF_WIFI_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Interface description - inf-desc",
|
||||
"Interface status - inf-status",
|
||||
"Connection status - status",
|
||||
"Connection SSID - ssid",
|
||||
"Connection BSSID - bssid",
|
||||
"Connection protocol - protocol",
|
||||
"Connection signal quality (percentage num) - signal-quality",
|
||||
"Connection RX rate - rx-rate",
|
||||
"Connection TX rate - tx-rate",
|
||||
"Connection Security algorithm - security",
|
||||
"Connection signal quality (percentage bar) - signal-quality-bar",
|
||||
"Connection channel number - channel",
|
||||
"Connection channel band in GHz - band",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_WIFI_MODULE_NAME,
|
||||
.description = "Print connected Wi-Fi info (SSID, connection and security protocol)",
|
||||
.parseCommandOptions = (void*) ffParseWifiCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseWifiJsonObject,
|
||||
.printModule = (void*) ffPrintWifi,
|
||||
.generateJsonResult = (void*) ffGenerateWifiJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateWifiJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Interface description", "inf-desc"},
|
||||
{"Interface status", "inf-status"},
|
||||
{"Connection status", "status"},
|
||||
{"Connection SSID", "ssid"},
|
||||
{"Connection BSSID", "bssid"},
|
||||
{"Connection protocol", "protocol"},
|
||||
{"Connection signal quality (percentage num)", "signal-quality"},
|
||||
{"Connection RX rate", "rx-rate"},
|
||||
{"Connection TX rate", "tx-rate"},
|
||||
{"Connection Security algorithm", "security"},
|
||||
{"Connection signal quality (percentage bar)", "signal-quality-bar"},
|
||||
{"Connection channel number", "channel"},
|
||||
{"Connection channel band in GHz", "band"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitWifiOptions(FFWifiOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_WIFI_MODULE_NAME,
|
||||
"Print connected Wi-Fi info (SSID, connection and security protocol)",
|
||||
ffParseWifiCommandOptions,
|
||||
ffParseWifiJsonObject,
|
||||
ffPrintWifi,
|
||||
ffGenerateWifiJsonResult,
|
||||
ffPrintWifiHelpFormat,
|
||||
ffGenerateWifiJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 20, 0 };
|
||||
|
||||
+17
-23
@@ -5,8 +5,6 @@
|
||||
#include "modules/wm/wm.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_WM_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintWM(FFWMOptions* options)
|
||||
{
|
||||
const FFDisplayServerResult* result = ffConnectDisplayServer();
|
||||
@@ -45,7 +43,7 @@ void ffPrintWM(FFWMOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WM_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_WM_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(result->wmProcessName, "process-name"),
|
||||
FF_FORMAT_ARG(result->wmPrettyName, "pretty-name"),
|
||||
FF_FORMAT_ARG(result->wmProtocolName, "protocol-name"),
|
||||
@@ -125,29 +123,25 @@ void ffGenerateWMJsonResult(FF_MAYBE_UNUSED FFWMOptions* options, yyjson_mut_doc
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "pluginName", &pluginName);
|
||||
}
|
||||
|
||||
void ffPrintWMHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WM_MODULE_NAME, "{2} ({3})", FF_WM_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"WM process name - process-name",
|
||||
"WM pretty name - pretty-name",
|
||||
"WM protocol name - protocol-name",
|
||||
"WM plugin name - plugin-name",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_WM_MODULE_NAME,
|
||||
.description = "Print window manager name and version",
|
||||
.parseCommandOptions = (void*) ffParseWMCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseWMJsonObject,
|
||||
.printModule = (void*) ffPrintWM,
|
||||
.generateJsonResult = (void*) ffGenerateWMJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateWMJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"WM process name", "process-name"},
|
||||
{"WM pretty name", "pretty-name"},
|
||||
{"WM protocol name", "protocol-name"},
|
||||
{"WM plugin name", "plugin-name"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitWMOptions(FFWMOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_WM_MODULE_NAME,
|
||||
"Print window manager name and version",
|
||||
ffParseWMCommandOptions,
|
||||
ffParseWMJsonObject,
|
||||
ffPrintWM,
|
||||
ffGenerateWMJsonResult,
|
||||
ffPrintWMHelpFormat,
|
||||
ffGenerateWMJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->detectPlugin = false;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_WMTHEME_DISPLAY_NAME "WM Theme"
|
||||
#define FF_WMTHEME_NUM_FORMAT_ARGS 1
|
||||
|
||||
void ffPrintWMTheme(FFWMThemeOptions* options)
|
||||
{
|
||||
@@ -19,7 +18,7 @@ void ffPrintWMTheme(FFWMThemeOptions* options)
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_WMTHEME_NUM_FORMAT_ARGS, ((FFformatarg[]){
|
||||
FF_PRINT_FORMAT_CHECKED(FF_WMTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_FORMAT_ARG(themeOrError, "result"),
|
||||
}));
|
||||
}
|
||||
@@ -77,26 +76,22 @@ void ffGenerateWMThemeJsonResult(FF_MAYBE_UNUSED FFWMThemeOptions* options, yyjs
|
||||
yyjson_mut_obj_add_strbuf(doc, module, "result", &themeOrError);
|
||||
}
|
||||
|
||||
void ffPrintWMthemeHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_WMTHEME_MODULE_NAME, "{1}", FF_WMTHEME_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"WM theme - result",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_WMTHEME_MODULE_NAME,
|
||||
.description = "Print current theme of window manager",
|
||||
.parseCommandOptions = (void*) ffParseWMThemeCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseWMThemeJsonObject,
|
||||
.printModule = (void*) ffPrintWMTheme,
|
||||
.generateJsonResult = (void*) ffGenerateWMThemeJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateWMThemeJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"WM theme", "result"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitWMThemeOptions(FFWMThemeOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_WMTHEME_MODULE_NAME,
|
||||
"Print current theme of window manager",
|
||||
ffParseWMThemeCommandOptions,
|
||||
ffParseWMThemeJsonObject,
|
||||
ffPrintWMTheme,
|
||||
ffGenerateWMThemeJsonResult,
|
||||
ffPrintWMthemeHelpFormat,
|
||||
ffGenerateWMThemeJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
|
||||
+22
-28
@@ -5,8 +5,6 @@
|
||||
#include "modules/zpool/zpool.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_ZPOOL_NUM_FORMAT_ARGS 8
|
||||
|
||||
static void printZpool(FFZpoolOptions* options, FFZpoolResult* result, uint8_t index)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
@@ -20,7 +18,7 @@ static void printZpool(FFZpoolOptions* options, FFZpoolResult* result, uint8_t i
|
||||
else
|
||||
{
|
||||
ffStrbufClear(&buffer);
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, 3, ((FFformatarg[]){
|
||||
FF_PARSE_FORMAT_STRING_CHECKED(&buffer, &options->moduleArgs.key, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(index, "index"),
|
||||
FF_FORMAT_ARG(result->name, "name"),
|
||||
FF_FORMAT_ARG(options->moduleArgs.keyIcon, "icon"),
|
||||
@@ -64,7 +62,7 @@ static void printZpool(FFZpoolOptions* options, FFZpoolResult* result, uint8_t i
|
||||
if (percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
|
||||
ffPercentAppendBar(&fragPercentageBar, result->fragmentation, options->percent, &options->moduleArgs);
|
||||
|
||||
FF_PRINT_FORMAT_CHECKED(buffer.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_ZPOOL_NUM_FORMAT_ARGS, ((FFformatarg[]) {
|
||||
FF_PRINT_FORMAT_CHECKED(buffer.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, ((FFformatarg[]) {
|
||||
FF_FORMAT_ARG(result->name, "name"),
|
||||
FF_FORMAT_ARG(result->state, "state"),
|
||||
FF_FORMAT_ARG(usedPretty, "size-used"),
|
||||
@@ -182,33 +180,29 @@ void ffGenerateZpoolJsonResult(FF_MAYBE_UNUSED FFZpoolOptions* options, yyjson_m
|
||||
}
|
||||
}
|
||||
|
||||
void ffPrintZpoolHelpFormat(void)
|
||||
{
|
||||
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_ZPOOL_MODULE_NAME, "{3} / {4} ({5}, {6} frag)", FF_ZPOOL_NUM_FORMAT_ARGS, ((const char* []) {
|
||||
"Zpool name - name",
|
||||
"Zpool state - state",
|
||||
"Size used - size-used",
|
||||
"Size total - size-total",
|
||||
"Size percentage num - size-percentage",
|
||||
"Fragmentation percentage num - frag-percentage",
|
||||
"Size percentage bar - size-percentage-bar",
|
||||
"Fragmentation percentage bar - frag-percentage-bar",
|
||||
}));
|
||||
}
|
||||
static FFModuleBaseInfo ffModuleInfo = {
|
||||
.name = FF_ZPOOL_MODULE_NAME,
|
||||
.description = "Print ZFS storage pools",
|
||||
.parseCommandOptions = (void*) ffParseZpoolCommandOptions,
|
||||
.parseJsonObject = (void*) ffParseZpoolJsonObject,
|
||||
.printModule = (void*) ffPrintZpool,
|
||||
.generateJsonResult = (void*) ffGenerateZpoolJsonResult,
|
||||
.generateJsonConfig = (void*) ffGenerateZpoolJsonConfig,
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Zpool name", "name"},
|
||||
{"Zpool state", "state"},
|
||||
{"Size used", "used"},
|
||||
{"Size total", "total"},
|
||||
{"Size percentage num", "used-percentage"},
|
||||
{"Fragmentation percentage num", "fragmentation-percentage"},
|
||||
{"Size percentage bar", "used-percentage-bar"},
|
||||
{"Fragmentation percentage bar", "fragmentation-percentage-bar"},
|
||||
}))
|
||||
};
|
||||
|
||||
void ffInitZpoolOptions(FFZpoolOptions* options)
|
||||
{
|
||||
ffOptionInitModuleBaseInfo(
|
||||
&options->moduleInfo,
|
||||
FF_ZPOOL_MODULE_NAME,
|
||||
"Print ZFS storage pools",
|
||||
ffParseZpoolCommandOptions,
|
||||
ffParseZpoolJsonObject,
|
||||
ffPrintZpool,
|
||||
ffGenerateZpoolJsonResult,
|
||||
ffPrintZpoolHelpFormat,
|
||||
ffGenerateZpoolJsonConfig
|
||||
);
|
||||
options->moduleInfo = ffModuleInfo;
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
options->percent = (FFPercentageModuleConfig) { 50, 80, 0 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user