|
2 | 2 | * @file |
3 | 3 | */ |
4 | 4 | #include "fetch.h" |
| 5 | +string Context::PACKAGE_DELIM = "; "s; |
5 | 6 |
|
6 | 7 | /** |
7 | 8 | * @returns gets the username |
@@ -352,60 +353,66 @@ vector<string> getGPU() |
352 | 353 | string getPackages() |
353 | 354 | { |
354 | 355 | auto red = Crayon{}.red(); |
355 | | - string pkg = ""; |
| 356 | + vector<string> pkgs; |
356 | 357 | if (Path::of("/bin/dpkg"s).isExecutable()) |
357 | 358 | { |
358 | 359 | auto c = Command::exec("dpkg -l"s); |
359 | | - pkg += to_string(c.getOutputLines()) + red.text(" dpkg; "); |
| 360 | + pkgs.push_back(to_string(c.getOutputLines()) + red.text(" dpkg"s)); |
360 | 361 | } |
361 | 362 | if (Path::of("/bin/snap"s).isExecutable()) |
362 | 363 | { |
363 | 364 | auto c = Command::exec("snap list"s); |
364 | | - pkg += to_string(c.getOutputLines()) + red.text(" snap; "); |
| 365 | + pkgs.push_back(to_string(c.getOutputLines()) + red.text(" snap"s)); |
365 | 366 | } |
366 | 367 | if (Path::of("/bin/pacman"s).isExecutable()) |
367 | 368 | { |
368 | 369 | auto c = Command::exec("pacman -Q"s); |
369 | | - pkg += to_string(c.getOutputLines()) + red.text(" pacman; "); |
| 370 | + pkgs.push_back(to_string(c.getOutputLines()) + red.text(" pacman"s)); |
370 | 371 | } |
371 | 372 | if (Path::of("/bin/flatpak"s).isExecutable()) |
372 | 373 | { |
373 | 374 | auto c = Command::exec("flatpak list"s); |
374 | | - pkg += to_string(c.getOutputLines()) + red.text(" flatpak; "); |
| 375 | + pkgs.push_back(to_string(c.getOutputLines()) + red.text(" flatpak"s)); |
375 | 376 | } |
376 | 377 | if (Path::of("/var/lib/rpm"s).isExecutable()) |
377 | 378 | { |
378 | 379 | auto c = Command::exec("rpm -qa"s); |
379 | | - pkg += to_string(c.getOutputLines()) + red.text(" rpm; "); |
| 380 | + pkgs.push_back(to_string(c.getOutputLines()) + red.text(" rpm"s)); |
380 | 381 | } |
381 | 382 | if (Path::of("/bin/npm"s).isExecutable()) |
382 | 383 | { |
383 | 384 | auto c = Command::exec("npm list"s); |
384 | | - pkg += to_string(c.getOutputLines()) + red.text(" npm; "); |
| 385 | + pkgs.push_back(to_string(c.getOutputLines()) + red.text(" npm"s)); |
385 | 386 | } |
386 | 387 | if (Path::of("/bin/emerge"s).isExecutable()) // gentoo |
387 | 388 | { |
388 | | - pkg += "not supported"s + red.text(" portage; "); |
| 389 | + pkgs.push_back("not supported"s + red.text(" portage"s)); |
389 | 390 | } |
390 | 391 | if (Path::of("/bin/xbps-install"s).isExecutable()) // void linux |
391 | 392 | { |
392 | 393 | auto c = Command::exec("flatpak list"s); |
393 | | - pkg += to_string(c.getOutputLines()) + red.text(" xbps; "); |
| 394 | + pkgs.push_back(to_string(c.getOutputLines()) + red.text(" xbps"s)); |
394 | 395 | } |
395 | 396 | if (Path::of("/bin/dnf"s).isExecutable()) // fedora |
396 | 397 | { |
397 | 398 | auto c = Command::exec("dnf list installed"s); |
398 | | - pkg += to_string(c.getOutputLines()) + red.text(" dnf; "); |
| 399 | + pkgs.push_back(to_string(c.getOutputLines()) + red.text(" dnf"s)); |
399 | 400 | } |
400 | 401 | if (Path::of("/bin/zypper"s).isExecutable()) // opensuse |
401 | 402 | { |
402 | 403 | auto c = Command::exec("zypper se --installed-only"s); |
403 | | - pkg += to_string(c.getOutputLines()) + red.text(" zypper; "); |
| 404 | + pkgs.push_back(to_string(c.getOutputLines()) + red.text(" zypper"s)); |
404 | 405 | } |
405 | 406 | if (Path::of("/home/linuxbrew/.linuxbrew/bin/brew"s).isExecutable()) |
406 | 407 | { |
407 | 408 | auto c = Command::exec("brew list | { tr '' '\n'; }"s); |
408 | | - pkg += to_string(c.getOutputLines()) + red.text(" brew; "); |
| 409 | + pkgs.push_back(to_string(c.getOutputLines()) + red.text(" brew"s)); |
| 410 | + } |
| 411 | + |
| 412 | + auto pkg = ""s; |
| 413 | + for (auto p : pkgs) |
| 414 | + { |
| 415 | + pkg += p + Context::PACKAGE_DELIM; |
409 | 416 | } |
410 | 417 |
|
411 | 418 | return pkg; |
|
0 commit comments