mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 08:13:44 +01:00
Global: refactor code of -h <module>-format
This commit is contained in:
@@ -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, "");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user