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