mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
Fastfetch: refactor command line option parsing code
1. improve performance 2. remove `-c` 3. rename `--recache` to `--logo-recache`, and remove `-r`
This commit is contained in:
parent
c888254f70
commit
e5e4c8bf88
@ -4,6 +4,8 @@ Changes:
|
|||||||
* Unescape strings only when parsing `.conf` files
|
* Unescape strings only when parsing `.conf` files
|
||||||
* Previously: `$ NO_CONFIG=1 fastfetch --os-key \\\\ -s os -l none` prints `\: *`. Note the backslashs are unescaped twice (once by shell and once by fastfetch).
|
* Previously: `$ NO_CONFIG=1 fastfetch --os-key \\\\ -s os -l none` prints `\: *`. Note the backslashs are unescaped twice (once by shell and once by fastfetch).
|
||||||
* Now: `$ NO_CONFIG=1 fastfetch --os-key \\\\ -s os -l none` prints `\\: *`
|
* Now: `$ NO_CONFIG=1 fastfetch --os-key \\\\ -s os -l none` prints `\\: *`
|
||||||
|
* Remove option shortcut `-c` (alias of `--color`), which is more commonly used as alias of `--config`
|
||||||
|
* Rename `--recache` to `--logo-recache` (which is used for regenerate image logo cache). Remove option shortcut `-r` (alias of `--recache`).
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
* Add `--key-width` for aligning the left edge of values, supported both for global `--key-width` and specific module `--module-key-width`
|
* Add `--key-width` for aligning the left edge of values, supported both for global `--key-width` and specific module `--module-key-width`
|
||||||
|
@ -253,6 +253,7 @@ file(GENERATE OUTPUT logo_builtin.h CONTENT "${LOGO_BUILTIN_H}")
|
|||||||
set(LIBFASTFETCH_SRC
|
set(LIBFASTFETCH_SRC
|
||||||
src/3rdparty/yyjson/yyjson.c
|
src/3rdparty/yyjson/yyjson.c
|
||||||
src/common/bar.c
|
src/common/bar.c
|
||||||
|
src/common/commandoption.c
|
||||||
src/common/font.c
|
src/common/font.c
|
||||||
src/common/format.c
|
src/common/format.c
|
||||||
src/common/init.c
|
src/common/init.c
|
||||||
|
@ -161,6 +161,11 @@
|
|||||||
"title": "Whether to preserve the aspect ratio of the logo. Supported by iTerm image protocol",
|
"title": "Whether to preserve the aspect ratio of the logo. Supported by iTerm image protocol",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
|
"recache": {
|
||||||
|
"type": "boolean",
|
||||||
|
"title": "If true, regenerate image logo cache",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
"chafa": {
|
"chafa": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "Chafa configuration. See chafa document for details",
|
"title": "Chafa configuration. See chafa document for details",
|
||||||
|
321
src/common/commandoption.c
Normal file
321
src/common/commandoption.c
Normal file
@ -0,0 +1,321 @@
|
|||||||
|
#include "commandoption.h"
|
||||||
|
#include "util/stringUtils.h"
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
static inline bool tryModule(const char* type, void* options)
|
||||||
|
{
|
||||||
|
FFModuleBaseInfo* baseInfo = (FFModuleBaseInfo*) options;
|
||||||
|
if (ffStrEqualsIgnCase(type, baseInfo->name))
|
||||||
|
{
|
||||||
|
baseInfo->printModule(options);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ffParseModuleCommand(const char* type)
|
||||||
|
{
|
||||||
|
FFconfig* cfg = &instance.config;
|
||||||
|
switch (toupper(type[0]))
|
||||||
|
{
|
||||||
|
case 'B': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->battery) ||
|
||||||
|
tryModule(type, &cfg->bios) ||
|
||||||
|
tryModule(type, &cfg->bluetooth) ||
|
||||||
|
tryModule(type, &cfg->board) ||
|
||||||
|
tryModule(type, &cfg->break_) ||
|
||||||
|
tryModule(type, &cfg->brightness) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'C': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->chassis) ||
|
||||||
|
tryModule(type, &cfg->command) ||
|
||||||
|
tryModule(type, &cfg->colors) ||
|
||||||
|
tryModule(type, &cfg->cpu) ||
|
||||||
|
tryModule(type, &cfg->cpuUsage) ||
|
||||||
|
tryModule(type, &cfg->cursor) ||
|
||||||
|
tryModule(type, &cfg->custom) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'D': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->dateTime) ||
|
||||||
|
tryModule(type, &cfg->de) ||
|
||||||
|
tryModule(type, &cfg->display) ||
|
||||||
|
tryModule(type, &cfg->disk) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'F': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->font) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'G': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->gamepad) ||
|
||||||
|
tryModule(type, &cfg->gpu) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'H': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->host) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'I': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->icons) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'K': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->kernel) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'L': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->lm) ||
|
||||||
|
tryModule(type, &cfg->locale) ||
|
||||||
|
tryModule(type, &cfg->localIP) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'M': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->media) ||
|
||||||
|
tryModule(type, &cfg->memory) ||
|
||||||
|
tryModule(type, &cfg->monitor) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'O': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->openCL) ||
|
||||||
|
tryModule(type, &cfg->openGL) ||
|
||||||
|
tryModule(type, &cfg->os) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'P': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->packages) ||
|
||||||
|
tryModule(type, &cfg->player) ||
|
||||||
|
tryModule(type, &cfg->powerAdapter) ||
|
||||||
|
tryModule(type, &cfg->processes) ||
|
||||||
|
tryModule(type, &cfg->publicIP) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'S': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->separator) ||
|
||||||
|
tryModule(type, &cfg->shell) ||
|
||||||
|
tryModule(type, &cfg->sound) ||
|
||||||
|
tryModule(type, &cfg->swap) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'T': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->terminal) ||
|
||||||
|
tryModule(type, &cfg->terminalFont) ||
|
||||||
|
tryModule(type, &cfg->terminalSize) ||
|
||||||
|
tryModule(type, &cfg->title) ||
|
||||||
|
tryModule(type, &cfg->theme) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'U': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->uptime) ||
|
||||||
|
tryModule(type, &cfg->users) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'V': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->vulkan) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'W': {
|
||||||
|
return
|
||||||
|
tryModule(type, &cfg->wallpaper) ||
|
||||||
|
tryModule(type, &cfg->weather) ||
|
||||||
|
tryModule(type, &cfg->wm) ||
|
||||||
|
tryModule(type, &cfg->wifi) ||
|
||||||
|
tryModule(type, &cfg->wmTheme) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool tryModuleCommandOptions(const char* key, const char* value, void* options)
|
||||||
|
{
|
||||||
|
FFModuleBaseInfo* baseInfo = (FFModuleBaseInfo*) options;
|
||||||
|
return baseInfo->parseCommandOptions(options, key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ffParseModuleOptions(const char* key, const char* value)
|
||||||
|
{
|
||||||
|
if (!ffStrStartsWith(key, "--")) return false;
|
||||||
|
FFconfig* cfg = &instance.config;
|
||||||
|
|
||||||
|
switch (toupper(key[2]))
|
||||||
|
{
|
||||||
|
case 'B': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->battery) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->bios) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->bluetooth) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->board) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->break_) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->brightness) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'C': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->chassis) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->command) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->colors) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->cpu) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->cpuUsage) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->cursor) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->custom) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'D': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->dateTime) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->de) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->display) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->disk) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'F': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->font) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'G': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->gamepad) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->gpu) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'H': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->host) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'I': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->icons) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'K': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->kernel) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'L': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->lm) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->locale) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->localIP) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'M': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->media) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->memory) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->monitor) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'O': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->openCL) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->openGL) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->os) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'P': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->packages) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->player) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->powerAdapter) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->processes) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->publicIP) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'S': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->separator) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->shell) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->sound) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->swap) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'T': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->terminal) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->terminalFont) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->terminalSize) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->title) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->theme) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'U': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->uptime) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->users) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'V': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->vulkan) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'W': {
|
||||||
|
return
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->wallpaper) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->weather) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->wm) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->wifi) ||
|
||||||
|
tryModuleCommandOptions(key, value, &cfg->wmTheme) ||
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
11
src/common/commandoption.h
Normal file
11
src/common/commandoption.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef FF_INCLUDED_common_commandoption
|
||||||
|
#define FF_INCLUDED_common_commandoption
|
||||||
|
|
||||||
|
#include "fastfetch.h"
|
||||||
|
|
||||||
|
bool ffParseModuleCommand(const char* type);
|
||||||
|
bool ffParseModuleOptions(const char* key, const char* value);
|
||||||
|
|
||||||
|
#endif
|
@ -48,7 +48,6 @@ static void defaultConfig(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
instance.config.showErrors = false;
|
instance.config.showErrors = false;
|
||||||
instance.config.recache = false;
|
|
||||||
instance.config.allowSlowOperations = false;
|
instance.config.allowSlowOperations = false;
|
||||||
instance.config.pipe = !isatty(STDOUT_FILENO);
|
instance.config.pipe = !isatty(STDOUT_FILENO);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
typedef struct FFModuleBaseInfo
|
typedef struct FFModuleBaseInfo
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
void (*parseCommandOptions)(void* options, const char* key, const char* value);
|
bool (*parseCommandOptions)(void* options, const char* key, const char* value);
|
||||||
void (*parseJsonObject)(void* options, yyjson_val *module);
|
void (*parseJsonObject)(void* options, yyjson_val *module);
|
||||||
void (*printModule)(void* options);
|
void (*printModule)(void* options);
|
||||||
} FFModuleBaseInfo;
|
} FFModuleBaseInfo;
|
||||||
@ -15,7 +15,7 @@ typedef struct FFModuleBaseInfo
|
|||||||
static inline void ffOptionInitModuleBaseInfo(
|
static inline void ffOptionInitModuleBaseInfo(
|
||||||
FFModuleBaseInfo* baseInfo,
|
FFModuleBaseInfo* baseInfo,
|
||||||
const char* name,
|
const char* name,
|
||||||
void* parseCommandOptions, // void (*const parseCommandOptions)(void* options, const char* key, const char* value)
|
void* parseCommandOptions, // bool (*const parseCommandOptions)(void* options, const char* key, const char* value)
|
||||||
void* parseJsonObject, // void (*const parseJsonObject)(void* options, yyjson_val *module)
|
void* parseJsonObject, // void (*const parseJsonObject)(void* options, yyjson_val *module)
|
||||||
void* printModule // void (*const printModule)(void* options)
|
void* printModule // void (*const printModule)(void* options)
|
||||||
)
|
)
|
||||||
|
@ -40,6 +40,7 @@ Logo options:
|
|||||||
--logo-padding-right <padding>: Set the padding on the right of the logo
|
--logo-padding-right <padding>: Set the padding on the right of the logo
|
||||||
--logo-padding-top <padding>: Set the padding on the top of the logo
|
--logo-padding-top <padding>: Set the padding on the top of the logo
|
||||||
--logo-print-remaining <?value>: Whether to print the remaining logo, if it has more lines than modules to display
|
--logo-print-remaining <?value>: Whether to print the remaining logo, if it has more lines than modules to display
|
||||||
|
--logo-recache <?value>: If true, regenerate image logo cache
|
||||||
--file <file>: Short for --logo-type file --logo <file>
|
--file <file>: Short for --logo-type file --logo <file>
|
||||||
--file-raw <file>: Short for --logo-type file-raw --logo <file>
|
--file-raw <file>: Short for --logo-type file-raw --logo <file>
|
||||||
--data <data>: Short for --logo-type data --logo <data>
|
--data <data>: Short for --logo-type data --logo <data>
|
||||||
@ -58,9 +59,9 @@ Display options:
|
|||||||
-s,--structure <structure>: Set the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available.
|
-s,--structure <structure>: Set the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available.
|
||||||
--color-keys <color>: Set the color of the keys
|
--color-keys <color>: Set the color of the keys
|
||||||
--color-title <color>: Set the color of the title
|
--color-title <color>: Set the color of the title
|
||||||
|
--color <color>: Set the color of both the keys and title
|
||||||
--key-width <num>: Align the width of keys to <num> characters
|
--key-width <num>: Align the width of keys to <num> characters
|
||||||
--bright-color <?value>: Set if the keys, title and ASCII logo should be printed in bright color. Default is true
|
--bright-color <?value>: Set if the keys, title and ASCII logo should be printed in bright color. Default is true
|
||||||
-c,--color <color>: Set the color of both the keys and title
|
|
||||||
--separator <str>: Set the separator between key and value. Default is a colon with a space
|
--separator <str>: Set the separator between key and value. Default is a colon with a space
|
||||||
--set <key=value>: Hard set the value of a key
|
--set <key=value>: Hard set the value of a key
|
||||||
--set-keyless <key=value>: Hard set the value of a key, but don't print the key or the separator
|
--set-keyless <key=value>: Hard set the value of a key, but don't print the key or the separator
|
||||||
|
321
src/fastfetch.c
321
src/fastfetch.c
@ -1,4 +1,5 @@
|
|||||||
#include "fastfetch.h"
|
#include "fastfetch.h"
|
||||||
|
#include "common/commandoption.h"
|
||||||
#include "common/printing.h"
|
#include "common/printing.h"
|
||||||
#include "common/parsing.h"
|
#include "common/parsing.h"
|
||||||
#include "common/io/io.h"
|
#include "common/io/io.h"
|
||||||
@ -769,18 +770,7 @@ static inline void optionCheckString(const char* key, const char* value, FFstrbu
|
|||||||
ffStrbufEnsureFree(buffer, 63); //This is not needed, as ffStrbufSetS will resize capacity if needed, but giving a higher start should improve performance
|
ffStrbufEnsureFree(buffer, 63); //This is not needed, as ffStrbufSetS will resize capacity if needed, but giving a higher start should improve performance
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parseOption(FFdata* data, const char* key, const char* value)
|
static void printVersion()
|
||||||
{
|
|
||||||
///////////////////////
|
|
||||||
//Informative options//
|
|
||||||
///////////////////////
|
|
||||||
|
|
||||||
if(ffStrEqualsIgnCase(key, "-h") || ffStrEqualsIgnCase(key, "--help"))
|
|
||||||
{
|
|
||||||
printCommandHelp(value);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
else if(ffStrEqualsIgnCase(key, "-v") || ffStrEqualsIgnCase(key, "--version"))
|
|
||||||
{
|
{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#define FF_BUILD_TYPE "-debug"
|
#define FF_BUILD_TYPE "-debug"
|
||||||
@ -812,7 +802,22 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
|||||||
|
|
||||||
#undef FF_ARCHITECTURE
|
#undef FF_ARCHITECTURE
|
||||||
#undef FF_BUILD_TYPE
|
#undef FF_BUILD_TYPE
|
||||||
|
}
|
||||||
|
|
||||||
|
static void parseOption(FFdata* data, const char* key, const char* value)
|
||||||
|
{
|
||||||
|
///////////////////////
|
||||||
|
//Informative options//
|
||||||
|
///////////////////////
|
||||||
|
|
||||||
|
if(ffStrEqualsIgnCase(key, "-h") || ffStrEqualsIgnCase(key, "--help"))
|
||||||
|
{
|
||||||
|
printCommandHelp(value);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
else if(ffStrEqualsIgnCase(key, "-v") || ffStrEqualsIgnCase(key, "--version"))
|
||||||
|
{
|
||||||
|
printVersion();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if(ffStrEqualsIgnCase(key, "--version-raw"))
|
else if(ffStrEqualsIgnCase(key, "--version-raw"))
|
||||||
@ -929,8 +934,6 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
|||||||
//General options//
|
//General options//
|
||||||
///////////////////
|
///////////////////
|
||||||
|
|
||||||
else if(ffStrEqualsIgnCase(key, "-r") || ffStrEqualsIgnCase(key, "--recache"))
|
|
||||||
instance.config.recache = ffOptionParseBoolean(value);
|
|
||||||
else if(ffStrEqualsIgnCase(key, "--load-config"))
|
else if(ffStrEqualsIgnCase(key, "--load-config"))
|
||||||
optionParseConfigFile(data, key, value);
|
optionParseConfigFile(data, key, value);
|
||||||
else if(ffStrEqualsIgnCase(key, "--gen-config"))
|
else if(ffStrEqualsIgnCase(key, "--gen-config"))
|
||||||
@ -987,26 +990,32 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
|||||||
ffOptionParseString(key, value, &data->structure);
|
ffOptionParseString(key, value, &data->structure);
|
||||||
else if(ffStrEqualsIgnCase(key, "--separator"))
|
else if(ffStrEqualsIgnCase(key, "--separator"))
|
||||||
ffOptionParseString(key, value, &instance.config.keyValueSeparator);
|
ffOptionParseString(key, value, &instance.config.keyValueSeparator);
|
||||||
else if(ffStrEqualsIgnCase(key, "--color-keys"))
|
else if(ffStrStartsWith(key, "--color"))
|
||||||
{
|
{
|
||||||
optionCheckString(key, value, &instance.config.colorKeys);
|
const char* subkey = key + strlen("--color");
|
||||||
ffOptionParseColor(value, &instance.config.colorKeys);
|
if(*subkey == '\0')
|
||||||
}
|
{
|
||||||
else if(ffStrEqualsIgnCase(key, "--color-title"))
|
optionCheckString(key, value, &instance.config.colorKeys);
|
||||||
{
|
ffOptionParseColor(value, &instance.config.colorKeys);
|
||||||
optionCheckString(key, value, &instance.config.colorTitle);
|
ffStrbufSet(&instance.config.colorTitle, &instance.config.colorKeys);
|
||||||
ffOptionParseColor(value, &instance.config.colorTitle);
|
}
|
||||||
|
else if(ffStrEqualsIgnCase(subkey, "-keys"))
|
||||||
|
{
|
||||||
|
optionCheckString(key, value, &instance.config.colorKeys);
|
||||||
|
ffOptionParseColor(value, &instance.config.colorKeys);
|
||||||
|
}
|
||||||
|
else if(ffStrEqualsIgnCase(key, "-title"))
|
||||||
|
{
|
||||||
|
optionCheckString(key, value, &instance.config.colorTitle);
|
||||||
|
ffOptionParseColor(value, &instance.config.colorTitle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
else if(ffStrEqualsIgnCase(key, "--key-width"))
|
else if(ffStrEqualsIgnCase(key, "--key-width"))
|
||||||
instance.config.keyWidth = ffOptionParseUInt32(key, value);
|
instance.config.keyWidth = ffOptionParseUInt32(key, value);
|
||||||
else if(ffStrEqualsIgnCase(key, "--bright-color"))
|
else if(ffStrEqualsIgnCase(key, "--bright-color"))
|
||||||
instance.config.brightColor = ffOptionParseBoolean(value);
|
instance.config.brightColor = ffOptionParseBoolean(value);
|
||||||
else if(ffStrEqualsIgnCase(key, "-c") || ffStrEqualsIgnCase(key, "--color"))
|
|
||||||
{
|
|
||||||
optionCheckString(key, value, &instance.config.colorKeys);
|
|
||||||
ffOptionParseColor(value, &instance.config.colorKeys);
|
|
||||||
ffStrbufSet(&instance.config.colorTitle, &instance.config.colorKeys);
|
|
||||||
}
|
|
||||||
else if(ffStrEqualsIgnCase(key, "--binary-prefix"))
|
else if(ffStrEqualsIgnCase(key, "--binary-prefix"))
|
||||||
{
|
{
|
||||||
instance.config.binaryPrefixType = (FFBinaryPrefixType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
|
instance.config.binaryPrefixType = (FFBinaryPrefixType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
|
||||||
@ -1047,75 +1056,22 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
|||||||
}
|
}
|
||||||
else if(ffStrEqualsIgnCase(key, "--percent-type"))
|
else if(ffStrEqualsIgnCase(key, "--percent-type"))
|
||||||
instance.config.percentType = ffOptionParseUInt32(key, value);
|
instance.config.percentType = ffOptionParseUInt32(key, value);
|
||||||
else if(ffStrEqualsIgnCase(key, "--bar-char-elapsed"))
|
|
||||||
ffOptionParseString(key, value, &instance.config.barCharElapsed);
|
|
||||||
else if(ffStrEqualsIgnCase(key, "--bar-char-total"))
|
|
||||||
ffOptionParseString(key, value, &instance.config.barCharTotal);
|
|
||||||
else if(ffStrEqualsIgnCase(key, "--bar-width"))
|
|
||||||
instance.config.barWidth = (uint8_t) ffOptionParseUInt32(key, value);
|
|
||||||
else if(ffStrEqualsIgnCase(key, "--bar-border"))
|
|
||||||
instance.config.barBorder = ffOptionParseBoolean(value);
|
|
||||||
else if(ffStrEqualsIgnCase(key, "--no-buffer"))
|
else if(ffStrEqualsIgnCase(key, "--no-buffer"))
|
||||||
instance.config.noBuffer = ffOptionParseBoolean(value);
|
instance.config.noBuffer = ffOptionParseBoolean(value);
|
||||||
|
else if(ffStrStartsWithIgnCase(key, "--bar"))
|
||||||
///////////////////////
|
{
|
||||||
//Module args options//
|
const char* subkey = key + strlen("--bar");
|
||||||
///////////////////////
|
if(ffStrEqualsIgnCase(subkey, "-char-elapsed"))
|
||||||
|
ffOptionParseString(key, value, &instance.config.barCharElapsed);
|
||||||
else if(ffParseBatteryCommandOptions(&instance.config.battery, key, value)) {}
|
else if(ffStrEqualsIgnCase(subkey, "-char-total"))
|
||||||
else if(ffParseBiosCommandOptions(&instance.config.bios, key, value)) {}
|
ffOptionParseString(key, value, &instance.config.barCharTotal);
|
||||||
else if(ffParseBluetoothCommandOptions(&instance.config.bluetooth, key, value)) {}
|
else if(ffStrEqualsIgnCase(subkey, "-width"))
|
||||||
else if(ffParseBoardCommandOptions(&instance.config.board, key, value)) {}
|
instance.config.barWidth = (uint8_t) ffOptionParseUInt32(key, value);
|
||||||
else if(ffParseBreakCommandOptions(&instance.config.break_, key, value)) {}
|
else if(ffStrEqualsIgnCase(subkey, "-border"))
|
||||||
else if(ffParseBrightnessCommandOptions(&instance.config.brightness, key, value)) {}
|
instance.config.barBorder = ffOptionParseBoolean(value);
|
||||||
else if(ffParseCPUCommandOptions(&instance.config.cpu, key, value)) {}
|
else
|
||||||
else if(ffParseCPUUsageCommandOptions(&instance.config.cpuUsage, key, value)) {}
|
goto error;
|
||||||
else if(ffParseChassisCommandOptions(&instance.config.chassis, key, value)) {}
|
}
|
||||||
else if(ffParseColorsCommandOptions(&instance.config.colors, key, value)) {}
|
|
||||||
else if(ffParseCommandCommandOptions(&instance.config.command, key, value)) {}
|
|
||||||
else if(ffParseCursorCommandOptions(&instance.config.cursor, key, value)) {}
|
|
||||||
else if(ffParseCustomCommandOptions(&instance.config.custom, key, value)) {}
|
|
||||||
else if(ffParseDECommandOptions(&instance.config.de, key, value)) {}
|
|
||||||
else if(ffParseDateTimeCommandOptions(&instance.config.dateTime, key, value)) {}
|
|
||||||
else if(ffParseDiskCommandOptions(&instance.config.disk, key, value)) {}
|
|
||||||
else if(ffParseDisplayCommandOptions(&instance.config.display, key, value)) {}
|
|
||||||
else if(ffParseFontCommandOptions(&instance.config.font, key, value)) {}
|
|
||||||
else if(ffParseGPUCommandOptions(&instance.config.gpu, key, value)) {}
|
|
||||||
else if(ffParseGamepadCommandOptions(&instance.config.gamepad, key, value)) {}
|
|
||||||
else if(ffParseHostCommandOptions(&instance.config.host, key, value)) {}
|
|
||||||
else if(ffParseIconsCommandOptions(&instance.config.icons, key, value)) {}
|
|
||||||
else if(ffParseKernelCommandOptions(&instance.config.kernel, key, value)) {}
|
|
||||||
else if(ffParseLocalIpCommandOptions(&instance.config.localIP, key, value)) {}
|
|
||||||
else if(ffParseLocaleCommandOptions(&instance.config.locale, key, value)) {}
|
|
||||||
else if(ffParseMediaCommandOptions(&instance.config.media, key, value)) {}
|
|
||||||
else if(ffParseMemoryCommandOptions(&instance.config.memory, key, value)) {}
|
|
||||||
else if(ffParseMonitorCommandOptions(&instance.config.monitor, key, value)) {}
|
|
||||||
else if(ffParseOSCommandOptions(&instance.config.os, key, value)) {}
|
|
||||||
else if(ffParseOSCommandOptions(&instance.config.os, key, value)) {}
|
|
||||||
else if(ffParseOpenCLCommandOptions(&instance.config.openCL, key, value)) {}
|
|
||||||
else if(ffParseOpenGLCommandOptions(&instance.config.openGL, key, value)) {}
|
|
||||||
else if(ffParsePackagesCommandOptions(&instance.config.packages, key, value)) {}
|
|
||||||
else if(ffParsePlayerCommandOptions(&instance.config.player, key, value)) {}
|
|
||||||
else if(ffParsePowerAdapterCommandOptions(&instance.config.powerAdapter, key, value)) {}
|
|
||||||
else if(ffParseProcessesCommandOptions(&instance.config.processes, key, value)) {}
|
|
||||||
else if(ffParsePublicIpCommandOptions(&instance.config.publicIP, key, value)) {}
|
|
||||||
else if(ffParseSeparatorCommandOptions(&instance.config.separator, key, value)) {}
|
|
||||||
else if(ffParseShellCommandOptions(&instance.config.shell, key, value)) {}
|
|
||||||
else if(ffParseSoundCommandOptions(&instance.config.sound, key, value)) {}
|
|
||||||
else if(ffParseSwapCommandOptions(&instance.config.swap, key, value)) {}
|
|
||||||
else if(ffParseTerminalCommandOptions(&instance.config.terminal, key, value)) {}
|
|
||||||
else if(ffParseTerminalFontCommandOptions(&instance.config.terminalFont, key, value)) {}
|
|
||||||
else if(ffParseTerminalSizeCommandOptions(&instance.config.terminalSize, key, value)) {}
|
|
||||||
else if(ffParseThemeCommandOptions(&instance.config.theme, key, value)) {}
|
|
||||||
else if(ffParseTitleCommandOptions(&instance.config.title, key, value)) {}
|
|
||||||
else if(ffParseUptimeCommandOptions(&instance.config.uptime, key, value)) {}
|
|
||||||
else if(ffParseUsersCommandOptions(&instance.config.users, key, value)) {}
|
|
||||||
else if(ffParseVulkanCommandOptions(&instance.config.vulkan, key, value)) {}
|
|
||||||
else if(ffParseWMCommandOptions(&instance.config.wm, key, value)) {}
|
|
||||||
else if(ffParseWMThemeCommandOptions(&instance.config.wmTheme, key, value)) {}
|
|
||||||
else if(ffParseWallpaperCommandOptions(&instance.config.wallpaper, key, value)) {}
|
|
||||||
else if(ffParseWeatherCommandOptions(&instance.config.weather, key, value)) {}
|
|
||||||
else if(ffParseWifiCommandOptions(&instance.config.wifi, key, value)) {}
|
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
//Library options//
|
//Library options//
|
||||||
@ -1176,6 +1132,12 @@ static void parseOption(FFdata* data, const char* key, const char* value)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////
|
||||||
|
//Module args options//
|
||||||
|
///////////////////////
|
||||||
|
|
||||||
|
else if(ffParseModuleOptions(key, value)) {}
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
//Unknown option//
|
//Unknown option//
|
||||||
//////////////////
|
//////////////////
|
||||||
@ -1222,6 +1184,13 @@ static void parseArguments(FFdata* data, int argc, const char** argv)
|
|||||||
|
|
||||||
for(int i = 1; i < argc; i++)
|
for(int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
|
const char* key = argv[i];
|
||||||
|
if(*key != '-')
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: invalid option: %s. An option must start with `-`\n", key);
|
||||||
|
exit(400);
|
||||||
|
}
|
||||||
|
|
||||||
if(i == argc - 1 || (
|
if(i == argc - 1 || (
|
||||||
*argv[i + 1] == '-' &&
|
*argv[i + 1] == '-' &&
|
||||||
strcasecmp(argv[i], "--separator-string") != 0 // Separator string can start with a -
|
strcasecmp(argv[i], "--separator-string") != 0 // Separator string can start with a -
|
||||||
@ -1236,166 +1205,6 @@ static void parseArguments(FFdata* data, int argc, const char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool tryModule(const char* type, void* options)
|
|
||||||
{
|
|
||||||
FFModuleBaseInfo* baseInfo = (FFModuleBaseInfo*) options;
|
|
||||||
if (ffStrEqualsIgnCase(type, baseInfo->name))
|
|
||||||
{
|
|
||||||
baseInfo->printModule(options);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool parseModuleCommand(const char* type)
|
|
||||||
{
|
|
||||||
FFconfig* cfg = &instance.config;
|
|
||||||
switch (toupper(type[0]))
|
|
||||||
{
|
|
||||||
case 'B': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->battery) ||
|
|
||||||
tryModule(type, &cfg->bios) ||
|
|
||||||
tryModule(type, &cfg->bluetooth) ||
|
|
||||||
tryModule(type, &cfg->board) ||
|
|
||||||
tryModule(type, &cfg->break_) ||
|
|
||||||
tryModule(type, &cfg->brightness) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'C': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->chassis) ||
|
|
||||||
tryModule(type, &cfg->command) ||
|
|
||||||
tryModule(type, &cfg->colors) ||
|
|
||||||
tryModule(type, &cfg->cpu) ||
|
|
||||||
tryModule(type, &cfg->cpuUsage) ||
|
|
||||||
tryModule(type, &cfg->cursor) ||
|
|
||||||
tryModule(type, &cfg->custom) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'D': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->dateTime) ||
|
|
||||||
tryModule(type, &cfg->de) ||
|
|
||||||
tryModule(type, &cfg->display) ||
|
|
||||||
tryModule(type, &cfg->disk) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'F': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->font) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'G': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->gamepad) ||
|
|
||||||
tryModule(type, &cfg->gpu) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'H': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->host) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'I': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->icons) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'K': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->kernel) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'L': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->lm) ||
|
|
||||||
tryModule(type, &cfg->locale) ||
|
|
||||||
tryModule(type, &cfg->localIP) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'M': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->media) ||
|
|
||||||
tryModule(type, &cfg->memory) ||
|
|
||||||
tryModule(type, &cfg->monitor) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'O': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->openCL) ||
|
|
||||||
tryModule(type, &cfg->openGL) ||
|
|
||||||
tryModule(type, &cfg->os) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'P': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->packages) ||
|
|
||||||
tryModule(type, &cfg->player) ||
|
|
||||||
tryModule(type, &cfg->powerAdapter) ||
|
|
||||||
tryModule(type, &cfg->processes) ||
|
|
||||||
tryModule(type, &cfg->publicIP) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'S': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->separator) ||
|
|
||||||
tryModule(type, &cfg->shell) ||
|
|
||||||
tryModule(type, &cfg->sound) ||
|
|
||||||
tryModule(type, &cfg->swap) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'T': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->terminal) ||
|
|
||||||
tryModule(type, &cfg->terminalFont) ||
|
|
||||||
tryModule(type, &cfg->terminalSize) ||
|
|
||||||
tryModule(type, &cfg->title) ||
|
|
||||||
tryModule(type, &cfg->theme) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'U': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->uptime) ||
|
|
||||||
tryModule(type, &cfg->users) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'V': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->vulkan) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'W': {
|
|
||||||
return
|
|
||||||
tryModule(type, &cfg->wallpaper) ||
|
|
||||||
tryModule(type, &cfg->weather) ||
|
|
||||||
tryModule(type, &cfg->wm) ||
|
|
||||||
tryModule(type, &cfg->wifi) ||
|
|
||||||
tryModule(type, &cfg->wmTheme) ||
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void parseStructureCommand(const char* line, FFlist* customValues)
|
static void parseStructureCommand(const char* line, FFlist* customValues)
|
||||||
{
|
{
|
||||||
// handle `--set` and `--set-keyless`
|
// handle `--set` and `--set-keyless`
|
||||||
@ -1413,7 +1222,7 @@ static void parseStructureCommand(const char* line, FFlist* customValues)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!parseModuleCommand(line))
|
if(!ffParseModuleCommand(line))
|
||||||
ffPrintErrorString(line, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "<no implementation provided>");
|
ffPrintErrorString(line, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "<no implementation provided>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ typedef struct FFconfig
|
|||||||
FFstrbuf keyValueSeparator;
|
FFstrbuf keyValueSeparator;
|
||||||
|
|
||||||
bool showErrors;
|
bool showErrors;
|
||||||
bool recache;
|
|
||||||
bool allowSlowOperations;
|
bool allowSlowOperations;
|
||||||
bool disableLinewrap;
|
bool disableLinewrap;
|
||||||
bool hideCursor;
|
bool hideCursor;
|
||||||
|
@ -698,7 +698,7 @@ static bool printImageIfExistsSlowPath(FFLogoType type, bool printError)
|
|||||||
ffStrbufAppendF(&requestData.cacheDir, "%u", requestData.logoPixelHeight);
|
ffStrbufAppendF(&requestData.cacheDir, "%u", requestData.logoPixelHeight);
|
||||||
ffStrbufAppendC(&requestData.cacheDir, '/');
|
ffStrbufAppendC(&requestData.cacheDir, '/');
|
||||||
|
|
||||||
if(!instance.config.recache && printCached(&requestData))
|
if(!instance.config.logo.recache && printCached(&requestData))
|
||||||
{
|
{
|
||||||
ffStrbufDestroy(&requestData.cacheDir);
|
ffStrbufDestroy(&requestData.cacheDir);
|
||||||
return true;
|
return true;
|
||||||
|
@ -16,6 +16,7 @@ void ffInitLogoOptions(FFLogoOptions* options)
|
|||||||
options->paddingRight = 4;
|
options->paddingRight = 4;
|
||||||
options->printRemaining = true;
|
options->printRemaining = true;
|
||||||
options->preserveAspectRadio = false;
|
options->preserveAspectRadio = false;
|
||||||
|
options->recache = false;
|
||||||
|
|
||||||
options->chafaFgOnly = false;
|
options->chafaFgOnly = false;
|
||||||
ffStrbufInitStatic(&options->chafaSymbols, "block+border+space-wide-inverted"); // Chafa default
|
ffStrbufInitStatic(&options->chafaSymbols, "block+border+space-wide-inverted"); // Chafa default
|
||||||
@ -113,6 +114,8 @@ logoType:
|
|||||||
options->printRemaining = ffOptionParseBoolean(value);
|
options->printRemaining = ffOptionParseBoolean(value);
|
||||||
else if(strcasecmp(subKey, "preserve-aspect-radio") == 0)
|
else if(strcasecmp(subKey, "preserve-aspect-radio") == 0)
|
||||||
options->preserveAspectRadio = ffOptionParseBoolean(value);
|
options->preserveAspectRadio = ffOptionParseBoolean(value);
|
||||||
|
else if(strcasecmp(subKey, "recache") == 0)
|
||||||
|
options->recache = ffOptionParseBoolean(value);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -334,6 +337,11 @@ const char* ffParseLogoJsonConfig(void)
|
|||||||
options->preserveAspectRadio = yyjson_get_bool(val);
|
options->preserveAspectRadio = yyjson_get_bool(val);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if (strcasecmp(key, "recache") == 0)
|
||||||
|
{
|
||||||
|
options->recache = yyjson_get_bool(val);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
else if (strcasecmp(key, "chafa") == 0)
|
else if (strcasecmp(key, "chafa") == 0)
|
||||||
{
|
{
|
||||||
if (!yyjson_is_obj(val))
|
if (!yyjson_is_obj(val))
|
||||||
|
@ -35,6 +35,7 @@ typedef struct FFLogoOptions
|
|||||||
uint32_t paddingRight;
|
uint32_t paddingRight;
|
||||||
bool printRemaining;
|
bool printRemaining;
|
||||||
bool preserveAspectRadio;
|
bool preserveAspectRadio;
|
||||||
|
bool recache;
|
||||||
|
|
||||||
bool chafaFgOnly;
|
bool chafaFgOnly;
|
||||||
FFstrbuf chafaSymbols;
|
FFstrbuf chafaSymbols;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user