From a44b8264af51284817ea96bcea0ff3f4fc5351f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 10 Nov 2023 15:47:09 +0800 Subject: [PATCH] Fastfetch: remove the old function of `--gen-config` The file `config_user.txt` has not been maintained for long. Let's remove it. --- CHANGELOG.md | 8 +- CMakeLists.txt | 3 - src/common/init.c | 2 +- src/data/config_system.txt | 16 -- src/data/config_user.jsonc | 41 --- src/data/config_user.txt | 519 ------------------------------------- src/data/help.txt | 5 +- src/fastfetch.c | 79 ++---- src/fastfetch.h | 2 +- 9 files changed, 32 insertions(+), 643 deletions(-) delete mode 100644 src/data/config_system.txt delete mode 100644 src/data/config_user.jsonc delete mode 100644 src/data/config_user.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index bab497143..8b9ecdc2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 2.3.0 + +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 + # 2.2.3 Features: @@ -8,7 +14,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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 06e5e4f59..b6362afd5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,9 +214,6 @@ function(fastfetch_load_text FILENAME OUTVAR) endfunction(fastfetch_load_text) fastfetch_load_text(src/data/structure.txt DATATEXT_STRUCTURE) -fastfetch_load_text(src/data/config_system.txt DATATEXT_CONFIG_SYSTEM) -fastfetch_load_text(src/data/config_user.txt DATATEXT_CONFIG_USER) -fastfetch_load_text(src/data/config_user.jsonc DATATEXT_CONFIG_USER_JSONC) fastfetch_load_text(src/data/help.txt DATATEXT_HELP) fastfetch_load_text(src/data/help_color.txt DATATEXT_HELP_COLOR) fastfetch_load_text(src/data/help_format.txt DATATEXT_HELP_FORMAT) diff --git a/src/common/init.c b/src/common/init.c index 5c5b2307a..0ebb4b144 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -144,7 +144,7 @@ static void destroyState(void) ffPlatformDestroy(&instance.state.platform); yyjson_doc_free(instance.state.configDoc); yyjson_mut_doc_free(instance.state.resultDoc); - ffStrbufDestroy(&instance.state.migrateConfigPath); + ffStrbufDestroy(&instance.state.genConfigPath); } void ffDestroyInstance(void) diff --git a/src/data/config_system.txt b/src/data/config_system.txt deleted file mode 100644 index 46f58c043..000000000 --- a/src/data/config_system.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Fastfetch system configuration -# This file sets the default config for all users of the system. - -# For more information about how configuration files work, -# see ~/.config/fastfetch/config.conf. -# All options that can be put there (or passed as argument) can be put here too. - -# Use fastfetch --print-config-system > /etc/fastfetch/config.conf -# to overwrite this file with the current default file. - -# User config option -# Sets if fastfetch should load user provided configuration. -# If this is off, fastfetch ignores the user config file and any passed arguments -# Must be true or false -# Default is true. -#--load-user-config true diff --git a/src/data/config_user.jsonc b/src/data/config_user.jsonc deleted file mode 100644 index 029f768e5..000000000 --- a/src/data/config_user.jsonc +++ /dev/null @@ -1,41 +0,0 @@ -// ~/.config/fastfetch/config.jsonc -// See https://github.com/fastfetch-cli/fastfetch/wiki/Configuration for more details -// See *.jsonc in https://github.com/fastfetch-cli/fastfetch/tree/dev/presets/examples for more examples -{ - "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", - "logo": { - "padding": { - "top": 2 - } - }, - "modules": [ - "title", - "separator", - "os", - "host", - "kernel", - "uptime", - "packages", - "shell", - "display", - "de", - "wm", - "wmtheme", - "theme", - "icons", - "font", - "cursor", - "terminal", - "terminalfont", - "cpu", - "gpu", - "memory", - "disk", - "localip", - "battery", - "poweradapter", - "locale", - "break", - "colors" - ] -} diff --git a/src/data/config_user.txt b/src/data/config_user.txt deleted file mode 100644 index c8a257ec5..000000000 --- a/src/data/config_user.txt +++ /dev/null @@ -1,519 +0,0 @@ -# Fastfetch configuration -# Write every argument in different lines. -# Direct arguments will overwrite the corresponding ones in this file. -# Argument keys are not case sensitive. -# Whitespaces are trimmed at the beginning and the end. -# Empty lines or lines starting with # are ignored. - -# This file was shipped with $" FASTFETCH_PROJECT_VERSION $". -# Use fastfetch --gen-config-force to overwrite this file with the current defaults - -# Below some often usefull options are listed. Uncomment and modify them so they take affect. -# Note that there are a lot more options than the ones listed here, take a look at "fastfetch --help". -# Of course all of them can be made persistent here too. - -# Config option: -# Load additional config files. -# Some are shipped with fastfetch, list them with "fastfetch --list-presets". -# Must be a path to a config file or the name of a shipped preset. -# The config file is completely loaded before continuing in the current file, so the placement of this option matters, as later options overwrite already set ones. -# Can be used multiple times to load multiple config files / presets. -#--load-config /path/to/config.txt - -# Structure option: -# Sets the modules to use and their order. -# Must be a list of module names, separated by colons. -# List available modules with "fastfetch --list-modules". -# Get the default structure with "fastfetch --print-structure". -#--structure $" FASTFETCH_DATATEXT_STRUCTURE $" - -# Multithreading option: -# Sets if fastfetch should use multiple threads to detect the values. -# Must be true or false. -# Default is true. -#--multithreading true - -# Print stat option: -# Sets if fastfetch should print time usage (in ms) for individual modules -# If true, it will also enable --show-errors -# Must be true or false. -# Default is false. -#--stat true - -# Slow operations option: -# Sets if fastfetch is allowed to use known slow operations to detect more / better values. -# Must be true or false. -# Default is false. -#--allow-slow-operations false - -# Linewrap option: -# Sets if fastfetch should disable linewrap during the run. -# Must be true or false. -# Default is true. -#--disable-linewrap true - -# Cursor option: -# Sets if fastfetch should hide the console cursor during the run. -# Must be true or false. -# Default is true. -#--hide-cursor true - -# Processing timeout option: -# Sets the timeout (ms) when waiting for child processes -# Must be an integer. -# Default is 1000 -#--processing-timeout 1000 - -# WMI timeout option: -# Sets the timeout (ms) for WMI queries. Windows only -# Must be an integer. -# Default is 5000 -#--wmi-timeout 5000 - -# Logo option: -# Sets the logo to use. -# List available logos with "fastfetch --list-logos". -# Print available logos with "fastfetch --print-logos". -# Must be the name of an available logo or a path to a text file containing a custom logo. -# Default is the current distribution. -#--logo arch - -# Logo type option: -# Sets the logo type to use. -# Must be auto, builtin, file, file-raw, data, data-raw, sixel, kitty or chafa. -# Default is auto. -#--logo-type auto - -# Logo width option: -# Sets the width of the logo (in characters) if the logo is an image. -# Must be a positive integer. -# Default is 65. -#--logo-width 65 - -# Logo height option: -# Sets the height of the logo (in characters) if the logo is an image. -# Must be a positive integer. -# Default is 0 (keeps aspect ration). -#--logo-height 0 - -# Logo color options: -# Overwrite a color in the logo. Also works for user provided logos. -# In the user logo, they replace $[1-9]. Use $$ to print a single $ sign. -# Must be linux console color codes or the name of a color. -# Default is the one specified by the logo. -# Use "fastfetch --help color" to learn more and see examples. -# Valid index range is [1-9]. -#--logo-color-1 red -#--logo-color-2 32 -# [...] -#--logo-color-9 yellow - -# Logo padding option: -# Adds a padding to the left and the right side of the logo. -# Must be a positive integer. -# Default is 0. -#--logo-padding 0 - -# Logo padding left option: -# Adds a padding to the left side of the logo. -# Must be a positive integer. -# Default is 0. -#--logo-padding-left 0 - -# Logo padding right option: -# Adds a padding to the right side of the logo. -# Must be a positive integer. -# Default is 0. -#--logo-padding-right 0 - -# Logo padding top option: -# Adds a padding to the top side of the logo. -# Must be a positive integer. -# Default is 0. -#--logo-padding-top 0 - -# Logo print remaining option: -# Sets if the remaining logo should be printed, it is has more lines than modules to show. -# Must be true or false. -# Default is true. -#--logo-print-remaining true - -# Color keys option: -# Sets the color of the keys. -# Must be linux console color codes or the name of a color. -# Default is the key color of the logo. -# Use "fastfetch --help color" to learn more and see examples. -#--color-keys magenta - -# Color title option: -# Sets the color of the title. -# Must be linux console color codes or the name of a color. -# Default is the title color of the logo. -# Use "fastfetch --help color" to learn more and see examples. -#--color-title magenta - -# Binary prefix option: -# Sets the binary prefix to use. -# Must be a IEC, SI or JEDEC. -# Default is IEC. -#--binary-prefix IEC - -# Size number of digits option: -# Sets the number of digits to keep after the decimal point when formatting sizes. -# Must be an possitive integer. -# Default is 2. -#--size-ndigits 2 - -# Size max prefix option: -# Sets the largest binary prefix to use when formatting sizes. -# Must be one of B, kB, MB, GB, TB, PB, EB, ZB, YB -# Default is YB. -#--size-max-prefix YB - -# Disable output buffer option: -# Sets if the stdout application buffer should be disabled. -# Must be true or false. -# Default is false. -#--no-buffer false - -# Title FQDN option: -# Sets if the title should use the fully qualified domain name. -# Must be true or false. -# Default is false. -#--title-fqdn false - -# Title user color option: -# Sets color of the user name (left part). -# Default is empty (use color of `--color-title`). -#--title-color-user - -# Title at color option: -# Sets color of the @ symbol (middle part). -# Default is empty (use color of `--color-title`). -#--title-color-at - -# Title host color option: -# Sets color of the host name (right part). -# Default is empty (use color of `--color-title`). -#--title-color-host - -# Separator option: -# Sets the string placed between a key and its value. -# Can be any string. -# Default is ": ". -#--separator ": " - -# Separator string option: -# Sets the string printed by the "separator" module (usually between title and rest of output) -# Must be any string. It is repated / cut to fit perfectly. -# Default is "-" -#--separator-string - - -# Public IP URL option: -# Sets the URL of public IP detection server to be used. -# Only HTTP protocol is supported, and the value should not contain "http://" prefix. -# Default is "ipinfo.io/ip". -#--publicip-url "ipinfo.io/ip" - -# Public IP timeout option: -# Sets the time to wait for the public ip server to respond. -# Must be a positive integer. -# Default is 0 (disabled). -#--publicip-timeout 0 - -# Weather location option: -# Sets the location to be used. It must be URI encoded (eg a whitespace must be encoded as `+`). -# Default is empty (guessing by public IP) -#--weather-location "Location" - -# Weather output format option: -# Sets the weather format to be used. It must be URI encoded. -# See: https://github.com/chubin/wttr.in#one-line-output -# Default is "%t+-+%C+(%l)". -#--weather-output-format "%t+-+%C+(%l)" - -# Weather timeout option: -# Sets the time to wait for the weather server (wttr.in) to respond. -# Must be a positive integer. -# Default is 0 (disabled). -#--weather-timeout 0 - -# OS file option -# Sets the path to the file containing the operating system information. -# Should be a valid path to an existing file. -# Default is /etc/os-release. -#--os-file /etc/os-release - -# Player name option -# Sets the name of the player. This is also used in song detection -# Must be the exact name of the player or a dbus address (e.g. org.mpris.MediaPlayer2.spotify) -# Default is the first match starting with org.mpris.MediaPlayer2. -#--player-name spotify - -# Display server force DRM option -# Sets if fastfetch should only use `/sys/class/drm` to detect displays if you get issues with the default behavior. -# Note DRM doesn't support refresh rate or scaled resolution detection. -# Only supported on Linux. -# Must be true or false. -# Default is false. -#--ds-force-drm false - -# Escape bedrock option -# Sets if fastfetch should escape the bedrock jail, if it detectes that it is running in one -# Must be true or false. -# Default is true. -#--escape-bedrock true - -# OpenGL option -# Sets with opengl context creation library to use -# Must be either auto, egl, glx or osmesa -# Default is auto. -#--opengl-library auto - -# GPU hide options -# Sets whether to hide certain gpu types -# Must be either true or false -# Default is false. -#--gpu-hide-integrated -#--gpu-hide-discrete - -# GPU detection options -# Forces using vulkan to detect GPUs -# which support video memory usage detection with `--allow-slow-operations` -# Must be either true or false -# Default is false. -#--gpu-force-vulkan - -# Disk show options -# Sets if certain types of disk should be printed -# Must be either true or false -# Default is false except for --disk-show-external. -#--disk-show-external true -#--disk-show-hidden false -#--disk-show-subvolumes false -#--disk-show-unknown false - -# Disk option -# A colon (semicolon on Windows) separated list of folder paths for the disk output -# This option override `--disk-show-*` options above -# Must be a string -# Default is "/:/home" ("C:\\;D:\\ ..." on Windows). -#--disk-folders /:/home - -# Bluetooth show disconnected option -# Sets if disconnected bluetooth devices should be printed -# Must be either true or false -# Default is false. -#--bluetooth-show-disconnected false - -# Display compact output option -# Sets if all displays should be printed in one line -# Must be either original (print pixel resolution) or scaled (print scaled resolution) -# Default is none. -#--display-compact-type none - -# Display detect name option -# Sets if display name should be detected and printed (if supported) -# Must be either true of false -# Default is false. -#--display-detect-name none - -# Display precise refresh rate option -# Sets if decimal refresh rates should not be rounded into integers when printing -# Must be either true (keep decimals) of false (round into integers) -# Default is false. -#--display-precise-refresh-rate false - -# Sound show all option -# Sets if all sound devices should be printed -# Must be either main, active or all. Default is main -# Default is main. -#--sound-type main - -# Percentage output type option -# Applies to all modules that prints percentage values. Currently memory, swap, disk, battery and CPU usage are supported. -# Only works with default format ( without --module-format option ). -# 0: prints none; 1: prints percent number only; 2: prints bar only; 3: prints both percent number and bar; 6: prints bar and hide other texts; 9: prints colored number -#--percent-type 1 - -# Key options: -# Sets the displayed key of a module -# Can be any string. Some of theme take an argument like a format string. See "fastfetch --help format" for help. -#--os-key OS -#--host-key Host -#--chassis-key Chassis -#--kernel-key Kernel -#--uptime-key Uptime -#--processes-key Processes -#--packages-key Packages -#--shell-key Shell -#--display-key Display {1} -#--brightness-key Brightness ({1}) -#--monitor-key Monitor -#--de-key DE -#--wm-key WM -#--wmtheme-key WM Theme -#--theme-key Theme -#--icons-key Icons -#--font-key Font -#--cursor-key Cursor -#--terminal-key Terminal -#--terminalfont-key Terminal Font -#--cpu-key CPU -#--cpuusage-key CPU Usage -#--gpu-key GPU {1} -#--memory-key Memory -#--swap-key Swap -#--disk-key Disk ({1}) -#--battery-key Battery {1} -#--poweradapter-key Power Adapter {1} -#--lm-key LM -#--locale-key Locale -#--localip-key Local IP ({1}) -#--netio-key Network IO ({1}) -#--publicip-key Public IP -#--wifi-key Wifi -#--weather-key Weather -#--player-key Media Player -#--media-key Media -#--datetime-key Date Time -#--version-key Version -#--vulkan-key Vulkan -#--opengl-key OpenGL -#--opencl-key OpenCL -#--users-key Users -#--bluetooth-key Bluetooth -#--sound-key Sound -#--gamepad-key Gamepad -#--wallpaper-key Wallpaper - -# Format options: -# Sets the format string for module values. -# For information on format strings, see "fastfetch --help format". -# To see the parameter they take and their default value, see "fastfetch --help *-format", e.g. "fastfetch --help os-format". -# An empty format string (As they are currently below) will behave as if it was not set. -#--title-format -#--os-format -#--host-format -#--chassis-format -#--kernel-format -#--uptime-format -#--processes-format -#--packages-format -#--shell-format -#--display-format -#--brightness-format -#--de-format -#--wm-format -#--wmtheme-format -#--theme-format -#--icons-format -#--font-format -#--cursor-format -#--terminal-format -#--terminalfont-format -#--cpu-format -#--cpuusage-format -#--gpu-format -#--memory-format -#--swap-format -#--disk-format -#--battery-format -#--poweradapter-format -#--lm-format -#--locale-format -#--localip-format -#--netio-format -#--publicip-format -#--weather-format -#--monitor-format -#--player-format -#--media-format -#--datetime-format -#--version-format -#--vulkan-format -#--opengl-format -#--opencl-format -#--users-format -#--bluetooth-format -#--sound-format -#--gamepad-format -#--wallpaper-format - -# Key color options: -# Overrides the global `--color-keys` for one specified module -#--title-key-color -#--os-key-color -#--host-key-color -#--chassis-key-color -#--kernel-key-color -#--uptime-key-color -#--processes-key-color -#--packages-key-color -#--shell-key-color -#--display-key-color -#--brightness-key-color -#--de-key-color -#--wm-key-color -#--wmtheme-key-color -#--theme-key-color -#--icons-key-color -#--font-key-color -#--cursor-key-color -#--terminal-key-color -#--terminalfont-key-color -#--cpu-key-color -#--cpuusage-key-color -#--gpu-key-color -#--memory-key-color -#--swap-key-color -#--disk-key-color -#--battery-key-color -#--poweradapter-key-color -#--lm-key-color -#--locale-key-color -#--localip-key-color -#--netio-key-color -#--publicip-key-color -#--weather-key-color -#--monitor-key-color -#--player-key-color -#--media-key-color -#--datetime-key-color -#--version-key-color -#--vulkan-key-color -#--opengl-key-color -#--opencl-key-color -#--users-key-color -#--bluetooth-key-color -#--sound-key-color -#--gamepad-key-color -#--wallpaper-key-color - -# Library options: -# Sets an user specific path to a library to load. -# Must be a valid path to a library. -#--lib-PCI /usr/lib/libpci.so -#--lib-vulkan /usr/lib/libvulkan.so (libMoltenVK.dylib on macOS) -#--lib-wayland /usr/lib/libwayland-client.so -#--lib-xcb-randr /usr/lib/libxcb-randr.so -#--lib-xcb /usr/lib/libxcb.so -#--lib-Xrandr /usr/lib/libXrandr.so -#--lib-X11 /usr/lib/libX11.so -#--lib-gio /usr/lib/libgio-2.0.so -#--lib-DConf /usr/lib/libdconf.so -#--lib-DBus /usr/lib/libdbus-1.so -#--lib-XFConf /usr/lib/libxfconf-0.so -#--lib-sqlite3 /usr/lib/libsqlite3.so -#--lib-rpm /usr/lib/librpm.so -#--lib-imagemagick /usr/lib/libMagickCore-7.Q16HDRI.so -#--lib-z /usr/lib/libz.so -#--lib-chafa /usr/lib/libchafa.so -#--lib-egl /usr/lib/libEGL.so -#--lib-glx /usr/lib/libGLX.so -#--lib-osmesa /usr/lib/libOSMesa.so -#--lib-opencl /usr/lib/libOpenCL.so -#--lib-freetype /data/data/com.termux/files/usr/lib -#--lib-pulse /usr/lib/libpulse.so -#--lib-ddcutil /usr/lib/libddcutil.so -#--lib-nm /usr/lib/libnm.so diff --git a/src/data/help.txt b/src/data/help.txt index 7d5d1b9c6..0c4aa46c4 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -19,9 +19,8 @@ Informative options: Config options: -c, --load-config : Load a config file or preset (+) - --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 - --migrate-config : Migrate old flag based config file to new JSONC format. Optional param `path` is the file path that new file should be write to + --gen-config : Generate a config file (or print the file if is `-`), with options specified in the command line (if any) + --gen-config-force : Generate a config file. Overwrite the existing one General options: --thread : Use separate threads to send HTTP requests diff --git a/src/fastfetch.c b/src/fastfetch.c index 44653b0bd..89ee82491 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -317,42 +317,27 @@ static bool parseConfigFile(FFdata* data, const char* path) return true; } -static void generateConfigFile(bool force, const char* type) +static void generateConfigFile(bool force, const char* filePath) { - if (!type) + if (!filePath) { - 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 = ffStrEqualsIgnCase(type, "jsonc"); - if (!isJsonc) - { - if (!ffStrEqualsIgnCase(type, "conf")) - { - 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"); - - if (!force && ffPathExists(filename->chars, FF_PATHTYPE_FILE)) - { - fprintf(stderr, "Config file exists in `%s`, use `--gen-config-force` to overwrite\n", filename->chars); - exit(1); + ffStrbufSet(&instance.state.genConfigPath, (FFstrbuf*) ffListGet(&instance.state.platform.configDirs, 0)); + ffStrbufAppendS(&instance.state.genConfigPath, "fastfetch/config.jsonc"); } else { - ffWriteFileData( - filename->chars, - isJsonc ? strlen(FASTFETCH_DATATEXT_CONFIG_USER_JSONC) : strlen(FASTFETCH_DATATEXT_CONFIG_USER), - isJsonc ? FASTFETCH_DATATEXT_CONFIG_USER_JSONC : FASTFETCH_DATATEXT_CONFIG_USER); - printf("A sample config file has been written in `%s`\n", filename->chars); + if (ffStrEqualsIgnCase(filePath, "conf") || ffStrEqualsIgnCase(filePath, "jsonc")) + { + fputs("Error: specifying file type is no longer supported\n", stderr); + exit(477); + } + ffStrbufSetS(&instance.state.genConfigPath, filePath); + } + + if (!force && ffPathExists(instance.state.genConfigPath.chars, FF_PATHTYPE_ANY)) + { + fprintf(stderr, "Error: file `%s` exists. Use `--gen-config-force` to overwrite\n", instance.state.genConfigPath.chars); + exit(477); } } @@ -493,31 +478,9 @@ static void parseCommand(FFdata* data, char* key, char* value) exit(0); } else if(ffStrEqualsIgnCase(key, "--gen-config")) - { generateConfigFile(false, value); - exit(0); - } else if(ffStrEqualsIgnCase(key, "--gen-config-force")) - { generateConfigFile(true, value); - exit(0); - } - else if (ffStrEqualsIgnCase(key, "--migrate-config")) - { - if (!value) - { - ffStrbufSet(&instance.state.migrateConfigPath, (FFstrbuf*) ffListGet(&instance.state.platform.configDirs, 0)); - ffStrbufAppendS(&instance.state.migrateConfigPath, "fastfetch/config.jsonc"); - } - else - ffStrbufSetS(&instance.state.migrateConfigPath, value); - - if (ffPathExists(instance.state.migrateConfigPath.chars, FF_PATHTYPE_ANY)) - { - fprintf(stderr, "Error: file `%s` exists. Aborting\n", instance.state.migrateConfigPath.chars); - exit(477); - } - } else if(ffStrEqualsIgnCase(key, "--load-user-config")) data->loadUserConfig = ffOptionParseBoolean(value); else if(ffStrEqualsIgnCase(key, "--format")) @@ -609,7 +572,7 @@ static void parseOption(FFdata* data, const char* key, const char* value) static void parseConfigFiles(FFdata* data) { - if (__builtin_expect(instance.state.migrateConfigPath.length == 0, true)) + if (__builtin_expect(instance.state.genConfigPath.length == 0, true)) { for (uint32_t i = instance.state.platform.configDirs.length; i > 0; --i) { @@ -712,7 +675,7 @@ static void run(FFdata* data) ffFinish(); } -static void migrateConfig(FFdata* data, const FFstrbuf* filename) +static void writeConfigFile(FFdata* data, const FFstrbuf* filename) { yyjson_mut_doc* doc = yyjson_mut_doc_new(NULL); yyjson_mut_val* root = yyjson_mut_obj(doc); @@ -730,7 +693,7 @@ static void migrateConfig(FFdata* data, const FFstrbuf* filename) else { if (yyjson_mut_write_file(filename->chars, doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, NULL, NULL)) - printf("The migrated config file has been written in `%s`\nYou may remove the old config file if everything works fine\n", filename->chars); + printf("The generated config file has been written in `%s`\n", filename->chars); else { printf("Error: failed to write file in `%s`\n", filename->chars); @@ -757,10 +720,10 @@ int main(int argc, char** argv) parseConfigFiles(&data); parseArguments(&data, argc, argv, (void*) parseOption); - if (__builtin_expect(instance.state.migrateConfigPath.length == 0, true)) + if (__builtin_expect(instance.state.genConfigPath.length == 0, true)) run(&data); else - migrateConfig(&data, &instance.state.migrateConfigPath); + writeConfigFile(&data, &instance.state.genConfigPath); ffStrbufDestroy(&data.structure); FF_LIST_FOR_EACH(FFCustomValue, customValue, data.customValues) diff --git a/src/fastfetch.h b/src/fastfetch.h index 502a48d40..b7c136501 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -47,7 +47,7 @@ typedef struct FFstate FFPlatform platform; yyjson_doc* configDoc; yyjson_mut_doc* resultDoc; - FFstrbuf migrateConfigPath; + FFstrbuf genConfigPath; } FFstate; typedef struct FFinstance