1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Handle color on multiple line in a cleaner way

When using ansible deployment on git push, git insert "remote:"
at the start of ansible output. If you force the color on ansible,
the "remote:" also get colored if the string to display is on
more than 1 line.

This change make sure that each end of line reset the color, instead
of reseting only at the end of the string.
This commit is contained in:
Michael Scherer 2016-06-16 19:17:05 +02:00 committed by Matt Clay
parent 5365b81d14
commit dc71f28642

View file

@ -70,7 +70,7 @@ def stringc(text, color):
"""String in color.""" """String in color."""
if ANSIBLE_COLOR: if ANSIBLE_COLOR:
return u"\033[%sm%s\033[0m" % (codeCodes[color], text) return "\n".join([u"\033[%sm%s\033[0m" % (codeCodes[color], t) for t in text.split('\n')])
else: else:
return text return text