Separator: add --separator-output-color

This commit is contained in:
李通洲
2024-05-08 16:11:16 +08:00
parent 459f159b1b
commit 9cb08d115a
4 changed files with 26 additions and 0 deletions
+3
View File
@@ -1772,6 +1772,9 @@
"description": "Set the string to be printed",
"type": "string",
"default": "-"
},
"outputColor": {
"$ref": "#/$defs/outputColor"
}
}
},
+8
View File
@@ -921,6 +921,14 @@
"default": "-"
}
},
{
"long": "separator-output-color",
"desc": "Set the color of the separator module",
"arg": {
"type": "color",
"default": "default"
}
},
{
"long": "disk-folders",
"desc": "A colon (semicolon on Windows) separated list of folder paths to be detected",
+1
View File
@@ -9,4 +9,5 @@ typedef struct FFSeparatorOptions
FFModuleBaseInfo moduleInfo;
FFstrbuf string;
FFstrbuf outputColor;
} FFSeparatorOptions;
+14
View File
@@ -43,6 +43,8 @@ void ffPrintSeparator(FFSeparatorOptions* options)
+ (fqdn ? platform->hostName.length : ffStrbufFirstIndexC(&platform->hostName, '.')); // host name
ffLogoPrintLine();
if(options->outputColor.length)
ffPrintColor(&options->outputColor);
if(__builtin_expect(options->string.length == 1, 1))
{
ffPrintCharTimes(options->string.chars[0], titleLength);
@@ -97,6 +99,12 @@ bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key
return true;
}
if (ffStrEqualsIgnCase(subKey, "output-color"))
{
ffOptionParseColor(value, &options->outputColor);
return true;
}
return false;
}
@@ -116,6 +124,12 @@ void ffParseSeparatorJsonObject(FFSeparatorOptions* options, yyjson_val* module)
continue;
}
if (ffStrEndsWithIgnCase(key, "outputColor"))
{
ffOptionParseColor(yyjson_get_str(val), &options->outputColor);
continue;
}
ffPrintError(FF_SEPARATOR_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Unknown JSON key %s", key);
}
}