mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-04 04:04:17 +01:00
Global: refactor code of -h <module>-format
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user