@@ -17,20 +17,37 @@ void ffPrintPackages(FFPackagesOptions* options)
17
17
return ;
18
18
}
19
19
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
+
20
27
if (options -> moduleArgs .outputFormat .length == 0 )
21
28
{
22
29
ffPrintLogoAndKey (FF_PACKAGES_MODULE_NAME , 0 , & options -> moduleArgs , FF_PRINT_TYPE_DEFAULT );
23
30
24
- #define FF_PRINT_PACKAGE_NAME (var , name ) \
31
+ #define FF_PRINT_PACKAGE_NAME (var , name ) { \
25
32
if(counts.var > 0) \
26
33
{ \
27
34
printf("%u (%s)", counts.var, (name)); \
28
35
if((all -= counts.var) > 0) \
29
36
fputs(", ", stdout); \
30
- };
37
+ } \
38
+ }
31
39
32
40
#define FF_PRINT_PACKAGE (name ) FF_PRINT_PACKAGE_NAME(name, #name)
33
41
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
+
34
51
uint32_t all = counts .all ;
35
52
if (counts .pacman > 0 )
36
53
{
@@ -45,34 +62,76 @@ void ffPrintPackages(FFPackagesOptions* options)
45
62
FF_PRINT_PACKAGE (emerge )
46
63
FF_PRINT_PACKAGE (eopkg )
47
64
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
+ }
51
75
FF_PRINT_PACKAGE (apk )
52
76
FF_PRINT_PACKAGE (pkg )
53
77
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
+ }
58
96
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
+ }
61
106
FF_PRINT_PACKAGE (macports )
62
107
FF_PRINT_PACKAGE (scoop )
63
108
FF_PRINT_PACKAGE (choco )
64
109
FF_PRINT_PACKAGE (pkgtool )
65
110
FF_PRINT_PACKAGE (paludis )
66
111
FF_PRINT_PACKAGE (winget )
67
112
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
+ }
70
122
FF_PRINT_PACKAGE (sorcery )
71
123
FF_PRINT_PACKAGE (lpkg )
72
124
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
+ }
76
135
FF_PRINT_PACKAGE (linglong )
77
136
FF_PRINT_PACKAGE (pacstall )
78
137
FF_PRINT_PACKAGE (mport )
@@ -84,11 +143,6 @@ void ffPrintPackages(FFPackagesOptions* options)
84
143
}
85
144
else
86
145
{
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 ;
92
146
FF_PRINT_FORMAT_CHECKED (FF_PACKAGES_MODULE_NAME , 0 , & options -> moduleArgs , FF_PRINT_TYPE_DEFAULT , ((FFformatarg []){
93
147
FF_FORMAT_ARG (counts .all , "all" ),
94
148
FF_FORMAT_ARG (counts .pacman , "pacman" ),
@@ -248,6 +302,12 @@ bool ffParsePackagesCommandOptions(FFPackagesOptions* options, const char* key,
248
302
return true;
249
303
}
250
304
305
+ if (ffStrEqualsIgnCase (subKey , "combined" ))
306
+ {
307
+ options -> combined = ffOptionParseBoolean (value );
308
+ return true;
309
+ }
310
+
251
311
return false;
252
312
}
253
313
@@ -360,6 +420,12 @@ void ffParsePackagesJsonObject(FFPackagesOptions* options, yyjson_val* module)
360
420
}
361
421
}
362
422
423
+ if (ffStrEqualsIgnCase (key , "combined" ))
424
+ {
425
+ options -> combined = yyjson_get_bool (val );
426
+ continue ;
427
+ }
428
+
363
429
ffPrintError (FF_PACKAGES_MODULE_NAME , 0 , & options -> moduleArgs , FF_PRINT_TYPE_DEFAULT , "Unknown JSON key %s" , key );
364
430
}
365
431
}
@@ -410,6 +476,9 @@ void ffGeneratePackagesJsonConfig(FFPackagesOptions* options, yyjson_mut_doc* do
410
476
FF_TEST_PACKAGE_NAME (XBPS )
411
477
#undef FF_TEST_PACKAGE_NAME
412
478
}
479
+
480
+ if (options - > combined != defaultOptions .combined )
481
+ yyjson_mut_obj_add_bool (doc , module , "combined ", options - > combined );
413
482
}
414
483
415
484
void ffGeneratePackagesJsonResult (FF_MAYBE_UNUSED FFPackagesOptions * options , yyjson_mut_doc * doc , yyjson_mut_val * module )
@@ -536,6 +605,7 @@ void ffInitPackagesOptions(FFPackagesOptions* options)
536
605
ffOptionInitModuleArg (& options -> moduleArgs , "" );
537
606
538
607
options -> disabled = FF_PACKAGES_DISABLE_LIST ;
608
+ options -> combined = false;
539
609
}
540
610
541
611
void ffDestroyPackagesOptions (FFPackagesOptions * options )
0 commit comments