2023-07-19 11:45:58 -04:00
|
|
|
#!/usr/bin/python
|
|
|
|
"""Add color and machine tags to remote pacman output."""
|
2021-11-29 17:02:55 -05:00
|
|
|
import termcolor
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
2021-12-02 13:50:15 -05:00
|
|
|
prefix = sys.argv[1] if len(sys.argv) > 1 else None
|
2023-07-19 11:45:58 -04:00
|
|
|
pacman_colors = {"==>": "green", "->": "blue"}
|
2021-11-29 17:02:55 -05:00
|
|
|
|
|
|
|
|
|
|
|
for line in sys.stdin:
|
2021-12-02 13:50:15 -05:00
|
|
|
if prefix:
|
|
|
|
print(prefix, end=" ")
|
2021-11-29 17:02:55 -05:00
|
|
|
if "==>" in line or "->" in line:
|
|
|
|
for part in re.split(r'(\s+)', line):
|
|
|
|
color = pacman_colors.get(part, "white")
|
|
|
|
|
2023-07-19 11:45:58 -04:00
|
|
|
termcolor.cprint(part, color, attrs=["bold"], end="")
|
2021-12-02 13:50:15 -05:00
|
|
|
else:
|
|
|
|
print(line, end="")
|