scripts/colors/pacman.py
Anna Schumaker 2e9699a52e deploypkg.zsh: Various Updates
* Clean up colors/pacman.py for colorful output
* Fixes for the .local/bin move
* Use the $COLORS and $BIN variables from common.zsh

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
2023-07-19 11:45:58 -04:00

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="")