Completion: tidy

This commit is contained in:
李通洲
2023-11-16 14:21:24 +08:00
parent 3f9462d7c8
commit f8ba138b8d
4 changed files with 42 additions and 22 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ Usage: fastfetch --color <color>
<color> must be a color encoding as ANSI escape sequences. It is inserted between "ESC[" and "m".
Infos about them can be found here: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters.
Examples:
--color 35: sets the color to pink
--color 35: sets the color to magenta. `--color magenta` is also supported
--color 4;92: sets the color to bright Green with underline
--color 5;104: blinking text on a blue background
If no color is set, the main color of the logo will be used.
+28 -10
View File
@@ -183,7 +183,7 @@ static void listDataPaths(void)
}
}
static void listModules()
static void listModules(bool pretty)
{
unsigned count = 0;
for (int i = 0; i <= 'Z' - 'A'; ++i)
@@ -191,7 +191,10 @@ static void listModules()
for (FFModuleBaseInfo** modules = ffModuleInfos[i]; *modules; ++modules)
{
++count;
printf("%d)%s%s\n", count, count > 9 ? " " : " ", (*modules)->name);
if (pretty)
printf("%d)%s%s\n", count, count > 9 ? " " : " ", (*modules)->name);
else
puts((*modules)->name);
}
}
}
@@ -450,9 +453,9 @@ static void parseCommand(FFdata* data, char* key, char* value)
{
const char* subkey = key + strlen("--list-");
if(ffStrEqualsIgnCase(subkey, "modules"))
listModules();
listModules(!value || !ffStrEqualsIgnCase(value, "autocompletion"));
else if(ffStrEqualsIgnCase(subkey, "presets"))
listAvailablePresets(ffOptionParseBoolean(value));
listAvailablePresets(!value || !ffStrEqualsIgnCase(value, "autocompletion"));
else if(ffStrEqualsIgnCase(subkey, "config-paths"))
listConfigPaths();
else if(ffStrEqualsIgnCase(subkey, "data-paths"))
@@ -461,13 +464,28 @@ static void parseCommand(FFdata* data, char* key, char* value)
ffListFeatures();
else if(ffStrEqualsIgnCase(subkey, "logos"))
{
puts("Builtin logos:");
ffLogoBuiltinList();
puts("\nCustom logos:");
listAvailableLogos();
if (value)
{
if (ffStrEqualsIgnCase(value, "autocompletion"))
ffLogoBuiltinListAutocompletion();
else if (ffStrEqualsIgnCase(value, "builtin"))
ffLogoBuiltinList();
else if (ffStrEqualsIgnCase(value, "custom"))
listAvailableLogos();
else
{
fprintf(stderr, "Error: unsupported logo type: %s\n", value);
exit(415);
}
}
else
{
puts("Builtin logos:");
ffLogoBuiltinList();
puts("\nCustom logos:");
listAvailableLogos();
}
}
else if(ffStrEqualsIgnCase(subkey, "logos-autocompletion"))
ffLogoBuiltinListAutocompletion();
else
{
fprintf(stderr, "Error: unsupported list option: %s\n", key);