21 lines
527 B
Python
21 lines
527 B
Python
#!/usr/bin/python
|
|
"""Add color and machine tags to remote pacman output."""
|
|
import termcolor
|
|
import re
|
|
import sys
|
|
|
|
prefix = sys.argv[1] if len(sys.argv) > 1 else None
|
|
pacman_colors = {"==>": "green", "->": "blue"}
|
|
|
|
|
|
for line in sys.stdin:
|
|
if prefix:
|
|
print(prefix, end=" ")
|
|
if "==>" in line or "->" in line:
|
|
for part in re.split(r'(\s+)', line):
|
|
color = pacman_colors.get(part, "white")
|
|
|
|
termcolor.cprint(part, color, attrs=["bold"], end="")
|
|
else:
|
|
print(line, end="")
|