mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 09:33:39 +01:00
Fastfetch: support -c none; remove --load-user-config
This commit is contained in:
+7
-3
@@ -1,10 +1,14 @@
|
||||
# 2.3.0
|
||||
|
||||
Changes:
|
||||
Config related changes:
|
||||
* The deprecated flag `--gen-config conf` is removed
|
||||
* Flag `--gen-config` now does the same thing as `--migrate-config`, which can be used as config migration and default config file generation. Flag `--migrate-config` is removed
|
||||
* Fastfetch now searchs for config files in the order of `fastfetch --list-config-paths`, and won't load other config if one is found.
|
||||
* Flag `--load-user-config` now works in command line flags, but not in config file.
|
||||
* The undocumented flag `--load-user-config` is removed. As an alternative, `--config none` can be used to disable loading config files.
|
||||
* `--config` (previously named `--load-config`) is now supported for command line arguments only. If specified, other config files won't be loaded, which works like other programs.
|
||||
* Config files will always be loaded before other command line flags being parsed. That is to say, command line flags will always override options defined in config files.
|
||||
|
||||
We are deprecating flags based config files (will be removed in v3.0.0). We suggest you migrate to json based config files.
|
||||
|
||||
Features:
|
||||
* Support Oils and elvish shell version detection (Shell)
|
||||
@@ -19,7 +23,7 @@ Bugfixes:
|
||||
* Fix terminal detection on NixOS (Terminal)
|
||||
|
||||
# 2.2.2
|
||||
g
|
||||
|
||||
Changes:
|
||||
* `--percent-type` now defaults to 9 (colored percentage numbers)
|
||||
* `fastfetch` now prints LocalIp module by default
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ for line in (string match -- ' -*' $whole_text)
|
||||
set res $res -x -a "true\tBool false\tBool"
|
||||
case '<config>'
|
||||
set -l presets (fastfetch --list-presets autocompletion)"\tPreset"
|
||||
set res $res -r -a "$presets"
|
||||
set res $res -r -a "none\tDisable $presets"
|
||||
case '<path>'
|
||||
set res $res -F -r
|
||||
case '<num>'
|
||||
|
||||
@@ -14,7 +14,7 @@ typedef struct FFdata
|
||||
{
|
||||
FFstrbuf structure;
|
||||
FFlist customValues; // List of FFCustomValue
|
||||
bool loadUserConfig;
|
||||
bool configLoaded;
|
||||
} FFdata;
|
||||
|
||||
bool ffParseModuleOptions(const char* key, const char* value);
|
||||
|
||||
+2
-3
@@ -17,10 +17,9 @@ Informative options:
|
||||
--print-structure: Print the default structure
|
||||
|
||||
Config options:
|
||||
-c, --config <config>: Load a config file or preset (+)
|
||||
-c, --config <config>: Specify the config file or preset to be loaded. If `none`, disable futher config loading (+)
|
||||
--gen-config <?path>: Generate a config file (or print it if <path> is `-`), with options specified in the command line (if any)
|
||||
--gen-config-force <?path>: Generate a config file. Overwrite the existing one
|
||||
--load-user-config <?bool>: Set if user config should be loaded. Default is true if env-var `NO_CONFIG` is not set
|
||||
|
||||
General options:
|
||||
--thread <?bool>: Use separate threads to send HTTP requests
|
||||
@@ -184,4 +183,4 @@ Module specific options:
|
||||
Parsing is not case sensitive. E.g. "--lib-PCI" is equal to "--Lib-Pci"
|
||||
If a value starts with a ?, it is optional. "true" will be used if not set.
|
||||
A (+) at the end indicates that more help can be printed with --help <option>
|
||||
All options can be made permanent with command `fastfetch <options> --migrate-config`
|
||||
All options can be made permanent with command `fastfetch <options> --gen-config`
|
||||
|
||||
+18
-10
@@ -345,18 +345,29 @@ static void generateConfigFile(bool force, const char* filePath)
|
||||
|
||||
static void optionParseConfigFile(FFdata* data, const char* key, const char* value)
|
||||
{
|
||||
if (data->configLoaded)
|
||||
{
|
||||
fprintf(stderr, "Error: only one config file can be loaded\n");
|
||||
exit(413);
|
||||
}
|
||||
|
||||
data->configLoaded = true;
|
||||
|
||||
if(value == NULL)
|
||||
{
|
||||
fprintf(stderr, "Error: usage: %s <file>\n", key);
|
||||
fprintf(stderr, "Error: usage: %s <config>\n", key);
|
||||
exit(413);
|
||||
}
|
||||
uint32_t fileNameLen = (uint32_t) strlen(value);
|
||||
if(fileNameLen == 0)
|
||||
{
|
||||
fprintf(stderr, "Error: usage: %s <file>\n", key);
|
||||
fprintf(stderr, "Error: usage: %s <config>\n", key);
|
||||
exit(413);
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(value, "none"))
|
||||
return;
|
||||
|
||||
bool isJsonConfig = fileNameLen > strlen(".jsonc") && strcasecmp(value + fileNameLen - strlen(".jsonc"), ".jsonc") == 0;
|
||||
|
||||
//Try to load as an absolute path
|
||||
@@ -498,8 +509,8 @@ static void parseCommand(FFdata* data, char* key, char* value)
|
||||
generateConfigFile(false, value);
|
||||
else if(ffStrEqualsIgnCase(key, "--gen-config-force"))
|
||||
generateConfigFile(true, value);
|
||||
else if(ffStrEqualsIgnCase(key, "--load-user-config"))
|
||||
data->loadUserConfig = ffOptionParseBoolean(value);
|
||||
else if(ffStrEqualsIgnCase(key, "-c") || ffStrEqualsIgnCase(key, "--load-config") || ffStrEqualsIgnCase(key, "--config"))
|
||||
optionParseConfigFile(data, key, value);
|
||||
else if(ffStrEqualsIgnCase(key, "--format"))
|
||||
{
|
||||
switch (ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
|
||||
@@ -535,10 +546,7 @@ static void parseCommand(FFdata* data, char* key, char* value)
|
||||
|
||||
static void parseOption(FFdata* data, const char* key, const char* value)
|
||||
{
|
||||
if(ffStrEqualsIgnCase(key, "-c") || ffStrEqualsIgnCase(key, "--load-config") || ffStrEqualsIgnCase(key, "--config"))
|
||||
optionParseConfigFile(data, key, value);
|
||||
|
||||
else if(ffStrEqualsIgnCase(key, "--set") || ffStrEqualsIgnCase(key, "--set-keyless"))
|
||||
if(ffStrEqualsIgnCase(key, "--set") || ffStrEqualsIgnCase(key, "--set-keyless"))
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY customValueStr = ffStrbufCreate();
|
||||
ffOptionParseString(key, value, &customValueStr);
|
||||
@@ -725,11 +733,11 @@ int main(int argc, char** argv)
|
||||
FFdata data = {
|
||||
.structure = ffStrbufCreate(),
|
||||
.customValues = ffListCreate(sizeof(FFCustomValue)),
|
||||
.loadUserConfig = !getenv("NO_CONFIG"),
|
||||
.configLoaded = false,
|
||||
};
|
||||
|
||||
parseArguments(&data, argc, argv, parseCommand);
|
||||
if(data.loadUserConfig)
|
||||
if(!data.configLoaded && !getenv("NO_CONFIG"))
|
||||
parseConfigFiles(&data);
|
||||
parseArguments(&data, argc, argv, (void*) parseOption);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user