mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
OS: make osFile a global option
`OS` is used by Module `Package`
This commit is contained in:
+4
-2
@@ -36,9 +36,10 @@ static void defaultConfig(FFinstance* instance)
|
||||
ffStrbufInit(&instance->config.colorKeys);
|
||||
ffStrbufInit(&instance->config.colorTitle);
|
||||
ffStrbufInitS(&instance->config.keyValueSeparator, ": ");
|
||||
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
ffStrbufInit(&instance->config.playerName);
|
||||
ffStrbufInit(&instance->config.osFile);
|
||||
#endif
|
||||
|
||||
instance->config.showErrors = false;
|
||||
@@ -254,9 +255,10 @@ static void destroyConfig(FFinstance* instance)
|
||||
ffStrbufDestroy(&instance->config.colorKeys);
|
||||
ffStrbufDestroy(&instance->config.colorTitle);
|
||||
ffStrbufDestroy(&instance->config.keyValueSeparator);
|
||||
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
ffStrbufDestroy(&instance->config.playerName);
|
||||
ffStrbufDestroy(&instance->config.osFile);
|
||||
#endif
|
||||
|
||||
ffDestroyTitleOptions(&instance->config.title);
|
||||
|
||||
@@ -304,10 +304,12 @@ const char* ffParseGeneralJsonConfig(FFinstance* instance)
|
||||
config->escapeBedrock = yyjson_get_bool(val);
|
||||
else if (strcasecmp(key, "pipe") == 0)
|
||||
config->pipe = yyjson_get_bool(val);
|
||||
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
else if (strcasecmp(key, "playerName") == 0)
|
||||
ffStrbufSetS(&config->playerName, yyjson_get_str(val));
|
||||
else if (strcasecmp(key, "osFile") == 0)
|
||||
ffStrbufSetS(&config->osFile, yyjson_get_str(val));
|
||||
#endif
|
||||
|
||||
else
|
||||
|
||||
@@ -96,9 +96,9 @@ static void getUbuntuFlavour(FFOSResult* result)
|
||||
|
||||
static void detectOS(FFOSResult* os, const FFinstance* instance)
|
||||
{
|
||||
if(instance->config.os.file.length > 0)
|
||||
if(instance->config.osFile.length > 0)
|
||||
{
|
||||
parseFile(instance->config.os.file.chars, os);
|
||||
parseFile(instance->config.osFile.chars, os);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -902,6 +902,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
else if(strcasecmp(key, "--player-name") == 0)
|
||||
optionParseString(key, value, &instance->config.playerName);
|
||||
else if (strcasecmp(key, "--os-file") == 0)
|
||||
optionParseString(key, value, &instance->config.osFile);
|
||||
#endif
|
||||
|
||||
////////////////
|
||||
|
||||
@@ -48,8 +48,10 @@ typedef struct FFconfig
|
||||
bool multithreading;
|
||||
bool stat;
|
||||
|
||||
// Module options that cannot be put in module option structure
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
FFstrbuf playerName;
|
||||
FFstrbuf osFile;
|
||||
#endif
|
||||
|
||||
FFTitleOptions title;
|
||||
|
||||
@@ -8,8 +8,4 @@ typedef struct FFOSOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFModuleArgs moduleArgs;
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
FFstrbuf file;
|
||||
#endif
|
||||
} FFOSOptions;
|
||||
|
||||
@@ -140,10 +140,6 @@ void ffInitOSOptions(FFOSOptions* options)
|
||||
{
|
||||
options->moduleName = FF_OS_MODULE_NAME;
|
||||
ffOptionInitModuleArg(&options->moduleArgs);
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
ffStrbufInit(&options->file);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char* value)
|
||||
@@ -153,23 +149,12 @@ bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char*
|
||||
if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs))
|
||||
return true;
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
if (strcasecmp(subKey, "file") == 0)
|
||||
{
|
||||
ffOptionParseString(key, value, &options->file);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ffDestroyOSOptions(FFOSOptions* options)
|
||||
{
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
ffStrbufDestroy(&options->file);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
@@ -190,14 +175,6 @@ void ffParseOSJsonObject(FFinstance* instance, yyjson_val* module)
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
|
||||
continue;
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
if (strcasecmp(key, "file") == 0)
|
||||
{
|
||||
ffStrbufSetS(&options.file, yyjson_get_str(val));
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user