Fix autocompletion of logos

This commit is contained in:
Linus Dierheimer
2021-11-09 16:53:08 +01:00
parent 27334f77cc
commit e54398f7b3
4 changed files with 24 additions and 7 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ __fastfetch_complete_path()
__fastfetch_complete_logo()
{
COMPREPLY=($(compgen -W "$(fastfetch --list-logos)" -- "$CURRENT_WORD"))
COMPREPLY=($(compgen -W "$(fastfetch --list-logos-autocompletion)" -- "$CURRENT_WORD"))
}
__fastfetch_complete_option()
+17 -6
View File
@@ -481,11 +481,11 @@ static FFlogo* getLogoVoid()
FF_LOGO_RETURN
}
typedef FFlogo*(*getLogoMethod)();
typedef FFlogo*(*GetLogoMethod)();
static getLogoMethod* getLogoMethods()
static GetLogoMethod* getLogoMethods()
{
static getLogoMethod logoMethods[] = {
static GetLogoMethod logoMethods[] = {
getLogoNone,
getLogoUnknown,
getLogoArch,
@@ -525,7 +525,7 @@ static bool logoHasName(FFlogo* logo, const char* name)
static bool loadLogoSet(FFinstance* instance, const char* name)
{
getLogoMethod* logoMethod = getLogoMethods();
GetLogoMethod* logoMethod = getLogoMethods();
while(*logoMethod != NULL)
{
@@ -743,7 +743,7 @@ void ffPrintRemainingLogo(FFinstance* instance)
void ffPrintLogos(FFinstance* instance)
{
getLogoMethod* methods = getLogoMethods();
GetLogoMethod* methods = getLogoMethods();
while(*methods != NULL)
{
@@ -757,7 +757,7 @@ void ffPrintLogos(FFinstance* instance)
void ffListLogos()
{
getLogoMethod* methods = getLogoMethods();
GetLogoMethod* methods = getLogoMethods();
while(*methods != NULL)
{
@@ -777,4 +777,15 @@ void ffListLogos()
}
}
void ffListLogosForAutocompletion()
{
GetLogoMethod* methods = getLogoMethods();
while(*methods != NULL)
{
printf("%s\n", (*methods)()->names[0]);
++methods;
}
}
#endif
+5
View File
@@ -515,6 +515,11 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
ffListLogos();
exit(0);
}
else if(strcasecmp(key, "--list-logos-autocompletion") == 0)
{
ffListLogosForAutocompletion();
exit(0);
}
else if(strcasecmp(key, "--print-logos") == 0)
{
ffPrintLogos(instance);
+1
View File
@@ -315,6 +315,7 @@ void ffPrintRemainingLogo(FFinstance* instance);
#ifndef FASTFETCH_BUILD_FLASHFATCH
void ffPrintLogos(FFinstance* instance);
void ffListLogos();
void ffListLogosForAutocompletion();
#endif
//common/format.c