From 08a717f5f7c25765dfa5041b29b2f00e061ce423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 30 Oct 2023 09:14:13 +0800 Subject: [PATCH] JsonConfig: more friendly error message --- src/fastfetch.c | 2 +- src/options/display.c | 4 ++++ src/options/general.c | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/fastfetch.c b/src/fastfetch.c index f42537aee..c815b5569 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -622,7 +622,7 @@ static void run(FFdata* data) (error = ffOptionsParseLibraryJsonConfig(&instance.config.library, root)) || false ) { - fputs(error, stderr); + fprintf(stderr, "JsonConfig Error: %s\n", error); exit(477); } } diff --git a/src/options/display.c b/src/options/display.c index 82385945b..a25dd1ca1 100644 --- a/src/options/display.c +++ b/src/options/display.c @@ -146,6 +146,10 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va options->noBuffer = yyjson_get_bool(val); else if (ffStrEqualsIgnCase(key, "keyWidth")) options->keyWidth = (uint32_t) yyjson_get_uint(val); + else if (ffStrStartsWithIgnCase(key, "percent")) + return "Property `display.percentX` has been changed to `display.percent.x`"; + else if (ffStrStartsWithIgnCase(key, "size")) + return "Property `display.sizeX` has been changed to `display.size.x`"; else return "Unknown display property"; } diff --git a/src/options/general.c b/src/options/general.c index c95062887..f4d1895a1 100644 --- a/src/options/general.c +++ b/src/options/general.c @@ -38,6 +38,11 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_va options->wmiTimeout = (int32_t) yyjson_get_int(val); #endif + else if (ffStrEqualsIgnCase(key, "stat")) + return "Property `general.stat` has been changed to `display.stat`"; + else if (ffStrEqualsIgnCase(key, "pipe")) + return "Property `general.pipe` has been changed to `display.pipe`"; + else return "Unknown general property"; }