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:
+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, "");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user