@@ -17,20 +17,37 @@ void ffPrintPackages(FFPackagesOptions* options)
1717 return ;
1818 }
1919
20+ uint32_t nixAll = counts .nixDefault + counts .nixSystem + counts .nixUser ;
21+ uint32_t flatpakAll = counts .flatpakSystem + counts .flatpakUser ;
22+ uint32_t brewAll = counts .brew + counts .brewCask ;
23+ uint32_t guixAll = counts .guixSystem + counts .guixUser + counts .guixHome ;
24+ uint32_t hpkgAll = counts .hpkgSystem + counts .hpkgUser ;
25+ uint32_t amAll = counts .amSystem + counts .amUser ;
26+
2027 if (options -> moduleArgs .outputFormat .length == 0 )
2128 {
2229 ffPrintLogoAndKey (FF_PACKAGES_MODULE_NAME , 0 , & options -> moduleArgs , FF_PRINT_TYPE_DEFAULT );
2330
24- #define FF_PRINT_PACKAGE_NAME (var , name ) \
31+ #define FF_PRINT_PACKAGE_NAME (var , name ) { \
2532 if(counts.var > 0) \
2633 { \
2734 printf("%u (%s)", counts.var, (name)); \
2835 if((all -= counts.var) > 0) \
2936 fputs(", ", stdout); \
30- };
37+ } \
38+ }
3139
3240 #define FF_PRINT_PACKAGE (name ) FF_PRINT_PACKAGE_NAME(name, #name)
3341
42+ #define FF_PRINT_PACKAGE_ALL (name ) {\
43+ if(name ## All > 0) \
44+ { \
45+ printf("%u (%s)", name ## All, #name); \
46+ if((all -= name ## All) > 0) \
47+ fputs(", ", stdout); \
48+ } \
49+ }
50+
3451 uint32_t all = counts .all ;
3552 if (counts .pacman > 0 )
3653 {
@@ -45,34 +62,76 @@ void ffPrintPackages(FFPackagesOptions* options)
4562 FF_PRINT_PACKAGE (emerge )
4663 FF_PRINT_PACKAGE (eopkg )
4764 FF_PRINT_PACKAGE (xbps )
48- FF_PRINT_PACKAGE_NAME (nixSystem , "nix - system ")
49- FF_PRINT_PACKAGE_NAME (nixUser , "nix - user ")
50- FF_PRINT_PACKAGE_NAME (nixDefault , "nix - default ")
65+ if (options - > combined )
66+ {
67+ FF_PRINT_PACKAGE_ALL (nix );
68+ }
69+ else
70+ {
71+ FF_PRINT_PACKAGE_NAME (nixSystem , "nix-system" )
72+ FF_PRINT_PACKAGE_NAME (nixUser , "nix-user" )
73+ FF_PRINT_PACKAGE_NAME (nixDefault , "nix-default" )
74+ }
5175 FF_PRINT_PACKAGE (apk )
5276 FF_PRINT_PACKAGE (pkg )
5377 FF_PRINT_PACKAGE (pkgsrc )
54- FF_PRINT_PACKAGE_NAME (hpkgSystem , counts .hpkgUser ? "hpkg - system " : "hpkg ")
55- FF_PRINT_PACKAGE_NAME (hpkgUser , "hpkg - user ")
56- FF_PRINT_PACKAGE_NAME (flatpakSystem , counts .flatpakUser ? "flatpak - system " : "flatpak ")
57- FF_PRINT_PACKAGE_NAME (flatpakUser , "flatpak - user ")
78+ if (options - > combined )
79+ {
80+ FF_PRINT_PACKAGE_ALL (hpkg )
81+ }
82+ else
83+ {
84+ FF_PRINT_PACKAGE_NAME (hpkgSystem , counts .hpkgUser ? "hpkg-system" : "hpkg" )
85+ FF_PRINT_PACKAGE_NAME (hpkgUser , "hpkg-user" )
86+ }
87+ if (options -> combined )
88+ {
89+ FF_PRINT_PACKAGE_ALL (flatpak );
90+ }
91+ else
92+ {
93+ FF_PRINT_PACKAGE_NAME (flatpakSystem , counts .flatpakUser ? "flatpak-system" : "flatpak" )
94+ FF_PRINT_PACKAGE_NAME (flatpakUser , "flatpak-user" )
95+ }
5896 FF_PRINT_PACKAGE (snap )
59- FF_PRINT_PACKAGE (brew )
60- FF_PRINT_PACKAGE_NAME (brewCask , "brew - cask ")
97+ if (options -> combined )
98+ {
99+ FF_PRINT_PACKAGE_ALL (brew );
100+ }
101+ else
102+ {
103+ FF_PRINT_PACKAGE_NAME (brew , "brew" )
104+ FF_PRINT_PACKAGE_NAME (brewCask , "brew-cask" )
105+ }
61106 FF_PRINT_PACKAGE (macports )
62107 FF_PRINT_PACKAGE (scoop )
63108 FF_PRINT_PACKAGE (choco )
64109 FF_PRINT_PACKAGE (pkgtool )
65110 FF_PRINT_PACKAGE (paludis )
66111 FF_PRINT_PACKAGE (winget )
67112 FF_PRINT_PACKAGE (opkg )
68- FF_PRINT_PACKAGE_NAME (amSystem , "am ")
69- FF_PRINT_PACKAGE_NAME (amUser , "appman ")
113+ if (options - > combined )
114+ {
115+ FF_PRINT_PACKAGE_ALL (am );
116+ }
117+ else
118+ {
119+ FF_PRINT_PACKAGE_NAME (amSystem , "am" )
120+ FF_PRINT_PACKAGE_NAME (amUser , "appman" )
121+ }
70122 FF_PRINT_PACKAGE (sorcery )
71123 FF_PRINT_PACKAGE (lpkg )
72124 FF_PRINT_PACKAGE (lpkgbuild )
73- FF_PRINT_PACKAGE_NAME (guixSystem , "guix - system ")
74- FF_PRINT_PACKAGE_NAME (guixUser , "guix - user ")
75- FF_PRINT_PACKAGE_NAME (guixHome , "guix - home ")
125+ if (options - > combined )
126+ {
127+ FF_PRINT_PACKAGE_ALL (guix );
128+ }
129+ else
130+ {
131+ FF_PRINT_PACKAGE_NAME (guixSystem , "guix-system" )
132+ FF_PRINT_PACKAGE_NAME (guixUser , "guix-user" )
133+ FF_PRINT_PACKAGE_NAME (guixHome , "guix-home" )
134+ }
76135 FF_PRINT_PACKAGE (linglong )
77136 FF_PRINT_PACKAGE (pacstall )
78137 FF_PRINT_PACKAGE (mport )
@@ -84,11 +143,6 @@ void ffPrintPackages(FFPackagesOptions* options)
84143 }
85144 else
86145 {
87- uint32_t nixAll = counts .nixDefault + counts .nixSystem + counts .nixUser ;
88- uint32_t flatpakAll = counts .flatpakSystem + counts .flatpakUser ;
89- uint32_t brewAll = counts .brew + counts .brewCask ;
90- uint32_t guixAll = counts .guixSystem + counts .guixUser + counts .guixHome ;
91- uint32_t hpkgAll = counts .hpkgSystem + counts .hpkgUser ;
92146 FF_PRINT_FORMAT_CHECKED (FF_PACKAGES_MODULE_NAME , 0 , & options -> moduleArgs , FF_PRINT_TYPE_DEFAULT , ((FFformatarg []){
93147 FF_FORMAT_ARG (counts .all , "all" ),
94148 FF_FORMAT_ARG (counts .pacman , "pacman" ),
@@ -248,6 +302,12 @@ bool ffParsePackagesCommandOptions(FFPackagesOptions* options, const char* key,
248302 return true;
249303 }
250304
305+ if (ffStrEqualsIgnCase (subKey , "combined" ))
306+ {
307+ options -> combined = ffOptionParseBoolean (value );
308+ return true;
309+ }
310+
251311 return false;
252312}
253313
@@ -360,6 +420,12 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module)
360420 }
361421 }
362422
423+ if (ffStrEqualsIgnCase (key , "combined" ))
424+ {
425+ options -> combined = yyjson_get_bool (val );
426+ continue ;
427+ }
428+
363429 ffPrintError (FF_PACKAGES_MODULE_NAME , 0 , & options -> moduleArgs , FF_PRINT_TYPE_DEFAULT , "Unknown JSON key %s" , key );
364430 }
365431}
@@ -410,6 +476,9 @@ void ffGeneratePackagesJsonConfig(FFPackagesOptions* options, yyjson_mut_doc* do
410476 FF_TEST_PACKAGE_NAME (XBPS )
411477 #undef FF_TEST_PACKAGE_NAME
412478 }
479+
480+ if (options - > combined != defaultOptions .combined )
481+ yyjson_mut_obj_add_bool (doc , module , "combined ", options - > combined );
413482}
414483
415484void ffGeneratePackagesJsonResult (FF_MAYBE_UNUSED FFPackagesOptions * options , yyjson_mut_doc * doc , yyjson_mut_val * module )
@@ -536,6 +605,7 @@ void ffInitPackagesOptions(FFPackagesOptions* options)
536605 ffOptionInitModuleArg (& options -> moduleArgs , "" );
537606
538607 options -> disabled = FF_PACKAGES_DISABLE_LIST ;
608+ options -> combined = false;
539609}
540610
541611void ffDestroyPackagesOptions (FFPackagesOptions * options )
0 commit comments