OS: prefer pretty names

Hopefully we can end the controversy.

Fix #1483 #1038
This commit is contained in:
李通洲
2025-01-06 08:58:14 +08:00
parent 88ebeb21e2
commit 6429c20466
4 changed files with 24 additions and 54 deletions
+10 -35
View File
@@ -51,38 +51,6 @@ static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result)
ffStrbufAppend(result, &os->variantID);
ffStrbufAppendC(result, ')');
}
//Append architecture if it is missing
if(!ffStrbufContainIgnCase(result, &instance.state.platform.sysinfo.architecture))
{
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &instance.state.platform.sysinfo.architecture);
}
}
static void buildOutputNixOS(const FFOSResult* os, FFstrbuf* result)
{
ffStrbufAppendS(result, "NixOS");
if(os->buildID.length > 0)
{
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &os->buildID);
}
if(os->codename.length > 0)
{
ffStrbufAppendS(result, " (");
ffStrbufAppendC(result, (char) toupper(os->codename.chars[0]));
ffStrbufAppendS(result, os->codename.chars + 1);
ffStrbufAppendC(result, ')');
}
if(instance.state.platform.sysinfo.architecture.length > 0)
{
ffStrbufAppendC(result, ' ');
ffStrbufAppend(result, &instance.state.platform.sysinfo.architecture);
}
}
void ffPrintOS(FFOSOptions* options)
@@ -99,11 +67,18 @@ void ffPrintOS(FFOSOptions* options)
{
FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate();
if(ffStrbufIgnCaseCompS(&os->id, "nixos") == 0)
buildOutputNixOS(os, &result);
if(os->prettyName.length > 0)
ffStrbufAppend(&result, &os->prettyName);
else
buildOutputDefault(os, &result);
//Append architecture if it is missing
if(!ffStrbufContainIgnCase(&result, &instance.state.platform.sysinfo.architecture))
{
ffStrbufAppendC(&result, ' ');
ffStrbufAppend(&result, &instance.state.platform.sysinfo.architecture);
}
ffPrintLogoAndKey(FF_OS_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
ffStrbufPutTo(&result, stdout);
}
@@ -195,7 +170,7 @@ static FFModuleBaseInfo ffModuleInfo = {
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
{"Name of the kernel", "sysname"},
{"Name of the OS", "name"},
{"Pretty name of the OS", "pretty-name"},
{"Pretty name of the OS, if available", "pretty-name"},
{"ID of the OS", "id"},
{"ID like of the OS", "id-like"},
{"Variant of the OS", "variant"},