Repository: fastfetch-cli/fastfetch
File: src/common/logo.c (C)

Code before:

void ffLoadLogoSet(FFconfig* config, const char* logo)
{
    if(strcasecmp(logo, "none") == 0)
    {
        loadNoneLogo(&config->logo);
        config->logo_spacing = 0; //This is wanted in most cases, so just set it
    }
    else if(strcasecmp(logo, "arch") == 0)
        loadArchLogo(&config->logo, config->colorLogo);
    else if(strcasecmp(logo, "artix") == 0)
        loadArtixLogo(&config->logo, config->colorLogo);
    else if(strcasecmp(logo, "ubuntu") == 0)
        loadUbuntuLogo(&config->logo, config->colorLogo);
    else if(strcasecmp(logo, "debian") == 0)
        loadDebianLogo(&config->logo, config->colorLogo);
    else if(strcasecmp(logo, "manjaro") == 0)
        loadManjaroLogo(&config->logo, config->colorLogo);
    else if(strcasecmp(logo, "void") == 0)
        loadVoidLogo(&config->logo, config->colorLogo);
    else if(strcasecmp(logo, "garuda") == 0)
        loadGarudaLogo(&config->logo, config->colorLogo);
    else if(strcasecmp(logo, "unknown") == 0)
        loadUnknownLogo(&config->logo);
    else if(access(logo, R_OK) == 0)
        loadLogoFromFile(&config->logo, config->colorLogo, logo);
    else
    {
        if(config->showErrors)
            printf(FASTFETCH_TEXT_MODIFIER_ERROR"Error: unknown logo: %s"FASTFETCH_TEXT_MODIFIER_RESET"\n", logo);
        loadUnknownLogo(&config->logo);
    }
}

void ffLoadLogo(FFinstance* instance)
{
    FFstrbuf cacheFilePath;
    ffStrbufInitA(&cacheFilePath, 64);
    ffGetCacheFilePath(instance, "logo.ffcl", NULL, &cacheFilePath);

    if(!instance->config.recache)
    {
        FFstrbuf content;
        ffStrbufInit(&content);
        ffAppendFileContent(cacheFilePath.chars, &content);

        if(content.length > 0)
        {
            ffLoadLogoSet(&instance->config, content.chars);
            ffStrbufDestroy(&content);
            ffStrbufDestroy(&cacheFilePath);

Review comment (suggestion):
I think we should also introduce an extra option for this. Maybe `--logo-file`? This way the user has better control about what logo is loaded. Anyway we can leave this a a fallback for `--logo`.

Code after:
    logo->width = logoWidth;
    logo->height = logoHeight;
}

void ffLoadLogoSet(FFconfig* config, const char* logo)
{
    if(config->readLogoFromFile) {
        ffLoadLogoFromFile(config, logo);
    } else {
        if(strcasecmp(logo, "none") == 0)
        {
            loadNoneLogo(&config->logo);
            config->logo_spacing = 0; //This is wanted in most cases, so just set it
        }
        else if(strcasecmp(logo, "arch") == 0)
            loadArchLogo(&config->logo, config->colorLogo);
        else if(strcasecmp(logo, "artix") == 0)
            loadArtixLogo(&config->logo, config->colorLogo);
        else if(strcasecmp(logo, "ubuntu") == 0)
            loadUbuntuLogo(&config->logo, config->colorLogo);
        else if(strcasecmp(logo, "debian") == 0)
            loadDebianLogo(&config->logo, config->colorLogo);
        else if(strcasecmp(logo, "manjaro") == 0)
            loadManjaroLogo(&config->logo, config->colorLogo);
        else if(strcasecmp(logo, "void") == 0)
            loadVoidLogo(&config->logo, config->colorLogo);
        else if(strcasecmp(logo, "garuda") == 0)
            loadGarudaLogo(&config->logo, config->colorLogo);
        else if(strcasecmp(logo, "unknown") == 0)
            loadUnknownLogo(&config->logo);
        else
            ffLoadLogoFromFile(config, logo);
    }
}

void ffLoadLogoFromFile(FFconfig* config, const char* logo) {
    if(access(logo, R_OK) == 0)
        loadLogoFromFile(&config->logo, config->colorLogo, &config->color, logo);
    else
    {
        if(config->showErrors)
            printf(FASTFETCH_TEXT_MODIFIER_ERROR"Error: unknown logo: %s"FASTFETCH_TEXT_MODIFIER_RESET"\n", logo);
        loadUnknownLogo(&config->logo);
    }
}

void ffLoadLogo(FFinstance* instance)
{
    FFstrbuf cacheFilePath;
    ffStrbufInitA(&cacheFilePath, 64);
    ffGetCacheFilePath(instance, "logo.ffcl", NULL, &cacheFilePath);