Skip to content

Commit 1dfa031

Browse files
authored
Fix several --help command related issues (#572)
* Help: fix wrong output for irrelevant commands * Help: fix `module-format` related issues * Help: remove unnecessary code
1 parent f78f97a commit 1dfa031

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

src/fastfetch.c

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static inline void printCommandHelp(const char* command)
9494
}
9595
else if(ffStrEqualsIgnCase(command, "bios-format"))
9696
{
97-
constructAndPrintCommandHelpFormat("bios", "{2} {3}", 4,
97+
constructAndPrintCommandHelpFormat("bios", "{4} ({2})", 4,
9898
"bios date",
9999
"bios release",
100100
"bios vendor",
@@ -103,15 +103,15 @@ static inline void printCommandHelp(const char* command)
103103
}
104104
else if(ffStrEqualsIgnCase(command, "board-format"))
105105
{
106-
constructAndPrintCommandHelpFormat("board", "{2} {3}", 3,
106+
constructAndPrintCommandHelpFormat("board", "{1} ({3})", 3,
107107
"board name",
108108
"board vendor",
109109
"board version"
110110
);
111111
}
112112
else if(ffStrEqualsIgnCase(command, "chassis-format"))
113113
{
114-
constructAndPrintCommandHelpFormat("chassis", "{2} {3}", 4,
114+
constructAndPrintCommandHelpFormat("chassis", "{1}", 3,
115115
"chassis type",
116116
"chassis vendor",
117117
"chassis version"
@@ -127,7 +127,7 @@ static inline void printCommandHelp(const char* command)
127127
}
128128
else if(ffStrEqualsIgnCase(command, "uptime-format"))
129129
{
130-
constructAndPrintCommandHelpFormat("uptime", "{} days {} hours {} mins", 4,
130+
constructAndPrintCommandHelpFormat("uptime", "{1} days {2} hours {3} mins", 4,
131131
"Days",
132132
"Hours",
133133
"Minutes",
@@ -136,7 +136,7 @@ static inline void printCommandHelp(const char* command)
136136
}
137137
else if(ffStrEqualsIgnCase(command, "processes-format"))
138138
{
139-
constructAndPrintCommandHelpFormat("processes", "{}", 1,
139+
constructAndPrintCommandHelpFormat("processes", "{1}", 1,
140140
"Count"
141141
);
142142
}
@@ -182,7 +182,7 @@ static inline void printCommandHelp(const char* command)
182182
}
183183
else if(ffStrEqualsIgnCase(command, "display-format"))
184184
{
185-
constructAndPrintCommandHelpFormat("display", "{}x{} @ {}Hz", 7,
185+
constructAndPrintCommandHelpFormat("display", "{1}x{2} @ {3}Hz", 8,
186186
"Screen width",
187187
"Screen height",
188188
"Screen refresh rate",
@@ -202,7 +202,7 @@ static inline void printCommandHelp(const char* command)
202202
}
203203
else if(ffStrEqualsIgnCase(command, "monitor-format"))
204204
{
205-
constructAndPrintCommandHelpFormat("monitor", "{}", 6,
205+
constructAndPrintCommandHelpFormat("monitor", "{2}x{3} px - {4}x{5} mm ({6} inches, {7} ppi)", 7,
206206
"Display name",
207207
"Display native resolution width in pixels",
208208
"Display native resolution height in pixels",
@@ -230,31 +230,31 @@ static inline void printCommandHelp(const char* command)
230230
}
231231
else if(ffStrEqualsIgnCase(command, "wmtheme-format"))
232232
{
233-
constructAndPrintCommandHelpFormat("wmtheme", "{}", 1,
233+
constructAndPrintCommandHelpFormat("wmtheme", "{1}", 1,
234234
"WM theme name"
235235
);
236236
}
237237
else if(ffStrEqualsIgnCase(command, "theme-format"))
238238
{
239-
constructAndPrintCommandHelpFormat("theme", "{}", 1,
239+
constructAndPrintCommandHelpFormat("theme", "{1}", 1,
240240
"Combined themes"
241241
);
242242
}
243243
else if(ffStrEqualsIgnCase(command, "icons-format"))
244244
{
245-
constructAndPrintCommandHelpFormat("icons", "{}", 1,
245+
constructAndPrintCommandHelpFormat("icons", "{1}", 1,
246246
"Combined icons"
247247
);
248248
}
249249
else if(ffStrEqualsIgnCase(command, "wallpaper-format"))
250250
{
251-
constructAndPrintCommandHelpFormat("wallpaper", "{}", 1,
251+
constructAndPrintCommandHelpFormat("wallpaper", "{1}", 1,
252252
"Wallpaper image file"
253253
);
254254
}
255255
else if(ffStrEqualsIgnCase(command, "font-format"))
256256
{
257-
constructAndPrintCommandHelpFormat("font", "{} [QT], {} [GTK2], {} [GTK3], {} [GTK4]", 4,
257+
constructAndPrintCommandHelpFormat("font", "{1} [QT], {2} [GTK2], {3} [GTK3], {4} [GTK4]", 4,
258258
"Font 1",
259259
"Font 2",
260260
"Font 3",
@@ -263,14 +263,14 @@ static inline void printCommandHelp(const char* command)
263263
}
264264
else if(ffStrEqualsIgnCase(command, "cursor-format"))
265265
{
266-
constructAndPrintCommandHelpFormat("cursor", "{} ({}pt)", 2,
266+
constructAndPrintCommandHelpFormat("cursor", "{1}", 2,
267267
"Cursor theme",
268268
"Cursor size"
269269
);
270270
}
271271
else if(ffStrEqualsIgnCase(command, "terminal-format"))
272272
{
273-
constructAndPrintCommandHelpFormat("terminal", "{3}", 10,
273+
constructAndPrintCommandHelpFormat("terminal", "{5} {6}", 6,
274274
"Terminal process name",
275275
"Terminal path with exe name",
276276
"Terminal exe name",
@@ -281,7 +281,7 @@ static inline void printCommandHelp(const char* command)
281281
}
282282
else if(ffStrEqualsIgnCase(command, "terminalfont-format"))
283283
{
284-
constructAndPrintCommandHelpFormat("terminalfont", "{}", 4,
284+
constructAndPrintCommandHelpFormat("terminalfont", "{1}", 4,
285285
"Terminal font",
286286
"Terminal font name",
287287
"Termianl font size",
@@ -290,7 +290,7 @@ static inline void printCommandHelp(const char* command)
290290
}
291291
else if(ffStrEqualsIgnCase(command, "cpu-format"))
292292
{
293-
constructAndPrintCommandHelpFormat("cpu", "{1} ({5}) @ {7}GHz", 8,
293+
constructAndPrintCommandHelpFormat("cpu", "{1} ({5}) @ {7} GHz", 8,
294294
"Name",
295295
"Vendor",
296296
"Physical core count",
@@ -303,13 +303,13 @@ static inline void printCommandHelp(const char* command)
303303
}
304304
else if(ffStrEqualsIgnCase(command, "cpuusage-format"))
305305
{
306-
constructAndPrintCommandHelpFormat("cpuusage", "{0}%", 1,
306+
constructAndPrintCommandHelpFormat("cpuusage", "{1}", 1,
307307
"CPU usage without percent mark"
308308
);
309309
}
310310
else if(ffStrEqualsIgnCase(command, "gpu-format"))
311311
{
312-
constructAndPrintCommandHelpFormat("gpu", "{} {}", 6,
312+
constructAndPrintCommandHelpFormat("gpu", "{1} {2}", 6,
313313
"GPU vendor",
314314
"GPU name",
315315
"GPU driver",
@@ -320,23 +320,23 @@ static inline void printCommandHelp(const char* command)
320320
}
321321
else if(ffStrEqualsIgnCase(command, "memory-format"))
322322
{
323-
constructAndPrintCommandHelpFormat("memory", "{} / {} ({}%)", 3,
323+
constructAndPrintCommandHelpFormat("memory", "{1} / {2} ({3})", 3,
324324
"Used size",
325325
"Total size",
326326
"Percentage used"
327327
);
328328
}
329329
else if(ffStrEqualsIgnCase(command, "swap-format"))
330330
{
331-
constructAndPrintCommandHelpFormat("swap", "{} / {} ({}%)", 3,
331+
constructAndPrintCommandHelpFormat("swap", "{1} / {2} ({3})", 3,
332332
"Used size",
333333
"Total size",
334334
"Percentage used"
335335
);
336336
}
337337
else if(ffStrEqualsIgnCase(command, "disk-format"))
338338
{
339-
constructAndPrintCommandHelpFormat("disk", "{1} / {2} ({3}%)", 9,
339+
constructAndPrintCommandHelpFormat("disk", "{1} / {2} ({3}) - {9}", 9,
340340
"Size used",
341341
"Size total",
342342
"Size percentage",
@@ -370,20 +370,21 @@ static inline void printCommandHelp(const char* command)
370370
}
371371
else if(ffStrEqualsIgnCase(command, "lm-format"))
372372
{
373-
constructAndPrintCommandHelpFormat("lm", "{} ({})", 2,
373+
constructAndPrintCommandHelpFormat("lm", "{1} {3} ({2})", 3,
374374
"LM service",
375-
"LM type"
375+
"LM type",
376+
"LM version"
376377
);
377378
}
378379
else if(ffStrEqualsIgnCase(command, "locale-format"))
379380
{
380-
constructAndPrintCommandHelpFormat("locale", "{}", 1,
381+
constructAndPrintCommandHelpFormat("locale", "{1}", 1,
381382
"Locale code"
382383
);
383384
}
384385
else if(ffStrEqualsIgnCase(command, "localip-format"))
385386
{
386-
constructAndPrintCommandHelpFormat("localip", "{}", 5,
387+
constructAndPrintCommandHelpFormat("localip", "{1}{5}", 5,
387388
"Local IPv4 address",
388389
"Local IPv6 address",
389390
"Physical (MAC) address",
@@ -393,13 +394,14 @@ static inline void printCommandHelp(const char* command)
393394
}
394395
else if(ffStrEqualsIgnCase(command, "publicip-format"))
395396
{
396-
constructAndPrintCommandHelpFormat("publicip", "{}", 1,
397-
"Public IP address"
397+
constructAndPrintCommandHelpFormat("publicip", "{1} ({2})", 2,
398+
"Public IP address",
399+
"Location"
398400
);
399401
}
400402
else if(ffStrEqualsIgnCase(command, "netio-format"))
401403
{
402-
constructAndPrintCommandHelpFormat("netio", "{}", 3,
404+
constructAndPrintCommandHelpFormat("netio", "{1} (IN) - {2} (OUT){4}", 4,
403405
"Size of data received per second (formatted)",
404406
"Size of data sent per second (formatted)",
405407
"Interface name",
@@ -408,7 +410,7 @@ static inline void printCommandHelp(const char* command)
408410
}
409411
else if(ffStrEqualsIgnCase(command, "wifi-format"))
410412
{
411-
constructAndPrintCommandHelpFormat("wifi", "{4} - {6}", 3,
413+
constructAndPrintCommandHelpFormat("wifi", "{4} - {10}", 10,
412414
"Interface description",
413415
"Interface status",
414416
"Connection status",
@@ -439,7 +441,7 @@ static inline void printCommandHelp(const char* command)
439441
"Album name"
440442
);
441443
}
442-
else if(ffStrEqualsIgnCase(command, "datetime-format") == 0 || ffStrEqualsIgnCase(command, "date-format") || ffStrEqualsIgnCase(command, "time-format"))
444+
else if(ffStrEqualsIgnCase(command, "datetime-format"))
443445
{
444446
constructAndPrintCommandHelpFormat("[date][time]", "{1}-{4}-{11} {14}:{18}:{20}", 20,
445447
"year",
@@ -466,7 +468,7 @@ static inline void printCommandHelp(const char* command)
466468
}
467469
else if(ffStrEqualsIgnCase(command, "version-format"))
468470
{
469-
constructAndPrintCommandHelpFormat("version", "{1} {2}{3} (5)", 6,
471+
constructAndPrintCommandHelpFormat("version", "{1} {2}{3} ({5})", 8,
470472
"Project name",
471473
"Version",
472474
"Version tweak",
@@ -487,7 +489,7 @@ static inline void printCommandHelp(const char* command)
487489
}
488490
else if(ffStrEqualsIgnCase(command, "opengl-format"))
489491
{
490-
constructAndPrintCommandHelpFormat("opengl", "{}", 3,
492+
constructAndPrintCommandHelpFormat("opengl", "{1}", 4,
491493
"version",
492494
"renderer",
493495
"vendor",
@@ -513,7 +515,7 @@ static inline void printCommandHelp(const char* command)
513515
}
514516
else if(ffStrEqualsIgnCase(command, "sound-format"))
515517
{
516-
constructAndPrintCommandHelpFormat("sound", "{2} (3%)", 4,
518+
constructAndPrintCommandHelpFormat("sound", "{2} ({3}%)", 4,
517519
"Main",
518520
"Name",
519521
"Volume",
@@ -522,13 +524,13 @@ static inline void printCommandHelp(const char* command)
522524
}
523525
else if(ffStrEqualsIgnCase(command, "gamepad-format"))
524526
{
525-
constructAndPrintCommandHelpFormat("gamepad", "{1}", 1,
527+
constructAndPrintCommandHelpFormat("gamepad", "{1}", 2,
526528
"Name",
527529
"Identifier"
528530
);
529531
}
530532
else
531-
fprintf(stderr, "No specific help for command %s provided\n", command);
533+
fprintf(stderr, "No specific help for command '%s' provided\n", command);
532534
}
533535

534536
static void listAvailablePresets(void)

0 commit comments

Comments
 (0)