pass manjaro pacman branch to format string

This commit is contained in:
Linus Dierheimer
2021-05-15 18:17:34 +02:00
parent d12edd02bf
commit 44339971bd
3 changed files with 7 additions and 6 deletions
+2 -1
View File
@@ -278,9 +278,10 @@ static inline void printCommandHelp(const char* command)
}
else if(strcasecmp(command, "packages-format") == 0)
{
constructAndPrintCommandHelpFormat("packages", "{2} (pacman), {3} (xbps), {4} (dpkg), {5}, (flatpak), {6} (snap)", 6,
constructAndPrintCommandHelpFormat("packages", "{2} (pacman){?3}[{3}]{?}, {4} (xbps), {5} (dpkg), {6}, (flatpak), {7} (snap)", 7,
"Number of all packages",
"Number of pacman packages",
"Pacman branch on manjaro",
"Number of xbps packages",
"Number of dpkg packages",
"Number of flatpak packages",
+5 -4
View File
@@ -4,7 +4,7 @@
#include <dirent.h>
#define FF_PACKAGES_MODULE_NAME "Packages"
#define FF_PACKAGES_NUM_FORMAT_ARGS 6
#define FF_PACKAGES_NUM_FORMAT_ARGS 7
static uint32_t getNumElements(const char* dirname, unsigned char type) {
uint32_t num_elements = 0;
@@ -68,9 +68,9 @@ void ffPrintPackages(FFinstance* instance)
ffPrintError(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packagesKey, &instance->config.packagesFormat, FF_PACKAGES_NUM_FORMAT_ARGS, "No packages from known package managers found");
return;
}
FFstrbuf manjaroBranch;
ffStrbufInit(&manjaroBranch);
if(ffParsePropFile("/etc/pacman-mirrors.conf", "Branch =", &manjaroBranch) && manjaroBranch.length == 0)
ffStrbufSetS(&manjaroBranch, "stable");
@@ -95,8 +95,6 @@ void ffPrintPackages(FFinstance* instance)
printf(", ");
};
ffStrbufDestroy(&manjaroBranch);
FF_PRINT_PACKAGE(xbps)
FF_PRINT_PACKAGE(dpkg)
FF_PRINT_PACKAGE(flatpak)
@@ -114,10 +112,13 @@ void ffPrintPackages(FFinstance* instance)
ffPrintFormatString(instance, FF_PACKAGES_MODULE_NAME, 0, &instance->config.packagesKey, &instance->config.packagesFormat, NULL, FF_PACKAGES_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_UINT, &all},
{FF_FORMAT_ARG_TYPE_UINT, &pacman},
{FF_FORMAT_ARG_TYPE_STRBUF, &manjaroBranch},
{FF_FORMAT_ARG_TYPE_UINT, &xbps},
{FF_FORMAT_ARG_TYPE_UINT, &dpkg},
{FF_FORMAT_ARG_TYPE_UINT, &flatpak},
{FF_FORMAT_ARG_TYPE_UINT, &snap}
});
}
ffStrbufDestroy(&manjaroBranch);
}
-1
View File
@@ -289,7 +289,6 @@ void ffStrbufTrimLeft(FFstrbuf* strbuf, char c)
void ffStrbufTrimRight(FFstrbuf* strbuf, char c)
{
while(strbuf->length > 0 && strbuf->chars[strbuf->length - 1] == c)
--strbuf->length;
strbuf->chars[strbuf->length] = '\0';