Enable monochrome output in the 'up' and 'logs' commands

Some systems, like Jenkins or other build servers, cannot correctly
render ANSI color codes.  The '--no-color' option enables monochrome
output in the 'up' and 'logs' commands to improve readability in those
systems.

Signed-off-by: Tim Freund <tim@freunds.net>
This commit is contained in:
Tim Freund 2014-08-07 00:03:29 -04:00
commit 69c241ba12
3 changed files with 35 additions and 11 deletions

View file

@ -137,11 +137,17 @@ class TopLevelCommand(Command):
"""
View output from containers.
Usage: logs [SERVICE...]
Usage: logs [options] [SERVICE...]
Options:
--no-color Produce monochrome output.
"""
containers = self.project.containers(service_names=options['SERVICE'], stopped=True)
monochrome = options['--no-color']
print("Attaching to", list_containers(containers))
LogPrinter(containers, attach_params={'logs': True}).run()
LogPrinter(containers, attach_params={'logs': True}, monochrome=monochrome).run()
def ps(self, options):
"""
@ -325,11 +331,14 @@ class TopLevelCommand(Command):
Options:
-d Detached mode: Run containers in the background,
print new container names.
--no-color Produce monochrome output.
--no-deps Don't start linked services.
--no-recreate If containers already exist, don't recreate them.
"""
detached = options['-d']
monochrome = options['--no-color']
start_links = not options['--no-deps']
recreate = not options['--no-recreate']
service_names = options['SERVICE']
@ -344,7 +353,7 @@ class TopLevelCommand(Command):
if not detached:
print("Attaching to", list_containers(to_attach))
log_printer = LogPrinter(to_attach, attach_params={"logs": True})
log_printer = LogPrinter(to_attach, attach_params={"logs": True}, monochrome=monochrome)
try:
log_printer.run()