From e707cf8464ef045d0d17728b5523b5f69c9abca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 26 Oct 2023 16:34:38 +0800 Subject: [PATCH] Migration: deprecate `--gen-config conf` --- CHANGELOG.md | 3 ++- README.md | 2 ++ src/data/help.txt | 4 ++-- src/fastfetch.c | 18 ++++++++++++------ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a62003508..cf518c70c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ This release introduces a new option `--migrate-config`, which migrates old flag Changes: * `--pipe` and `--stat` are moved from `general` options to `display` options. This affects cjson configuration. -* With the introduction of `--migrate-config`, the old flag based config file is deprecated, and will be removed in the future +* With the introduction of `--migrate-config`, the old flag based config file is deprecated, and will be removed in 3.0.0 (next major version) +* Support of `--gen-config conf` is deprecated accordingly, and will be removed in 2.3.0 (next minor version) Features: * Quirks for MIPS platforms (CPU, Linux) diff --git a/README.md b/README.md index 63c44c693..da2e4443c 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ There are [screenshots on different platforms](https://github.com/fastfetch-cli/ With customization and speed being two competing goals, this project actually builds two executables: + + * The main one is `fastfetch`, which can be very greatly configured via flags. These flags can be made persistent by modifying `$XDG_CONFIG_HOME/fastfetch/config.conf`. Use `fastfetch --gen-config conf` to generate one. To view the available options, run `fastfetch --help`. * The second executable is called `flashfetch`, which is configured at compile time to eliminate any possible overhead. Configuration of it can be very easily done in [`src/flashfetch.c`](src/flashfetch.c). diff --git a/src/data/help.txt b/src/data/help.txt index a83a81b8e..af8e2ba62 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -14,8 +14,8 @@ Informative options: --print-config-system: Print the default system config --print-config-user: Print the default user config --print-structure: Print the default structure - --gen-config : Generate a sample config file in the default path. Param `type` can be `jsonc` or `conf` - --gen-config-force : Generate a sample config file in the default path. Overwrite the existing one + --gen-config : Generate a sample config file in the default path. Param `type` can be `jsonc` or deprecated `conf` + --gen-config-force : Generate a sample config file in the default path. Overwrite the existing one General options: --load-config : Load a config file or preset (+) diff --git a/src/fastfetch.c b/src/fastfetch.c index 9c43dc978..f42537aee 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -236,18 +236,24 @@ static bool parseConfigFile(FFdata* data, const char* path) static void generateConfigFile(bool force, const char* type) { + if (!type) + { + fputs("Error: the config type (`jsonc` or `conf`) must be specified\n", stderr); + exit(1); + } + FFstrbuf* filename = (FFstrbuf*) ffListGet(&instance.state.platform.configDirs, 0); // Paths generated in `init.c/initConfigDirs` end with `/` - bool isJsonc = false; - if (type) + bool isJsonc = ffStrEqualsIgnCase(type, "jsonc"); + if (!isJsonc) { - if (ffStrEqualsIgnCase(type, "jsonc")) - isJsonc = true; - else if (!ffStrEqualsIgnCase(type, "conf")) + if (!ffStrEqualsIgnCase(type, "conf")) { - fputs("config type can only be `jsonc` or `conf`\n", stderr); + fputs("Error: config type can only be `jsonc` or `conf`\n", stderr); exit(1); } + else + fputs("Warning: support of flag based config type `conf` is deprecated, and may be removed in the future\n", stderr); } ffStrbufAppendS(filename, isJsonc ? "fastfetch/config.jsonc" : "fastfetch/config.conf");