From fc1bbb45b1a9a72d8f4d3fa00eeb1f8a3ebb3eb8 Mon Sep 17 00:00:00 2001 From: Ben Firshman Date: Sun, 19 Jan 2014 20:33:06 +0000 Subject: [PATCH] Add option to disable pseudo-tty on fig run Also disable tty if stdin is not a tty. --- fig/cli/main.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fig/cli/main.py b/fig/cli/main.py index 44422777f..1696a7c98 100644 --- a/fig/cli/main.py +++ b/fig/cli/main.py @@ -4,7 +4,6 @@ import logging import sys import re import signal -import sys from inspect import getdoc @@ -200,12 +199,20 @@ class TopLevelCommand(Command): Usage: run [options] SERVICE COMMAND [ARGS...] Options: - -d Detached mode: Run container in the background, print new container name + -d Detached mode: Run container in the background, print new + container name + -T Disable pseudo-tty allocation. By default `fig run` + allocates a TTY. """ service = self.project.get_service(options['SERVICE']) + + tty = True + if options['-d'] or options['-T'] or not sys.stdin.isatty(): + tty = False + container_options = { 'command': [options['COMMAND']] + options['ARGS'], - 'tty': not options['-d'], + 'tty': tty, 'stdin_open': not options['-d'], } container = service.create_container(one_off=True, **container_options) @@ -217,7 +224,7 @@ class TopLevelCommand(Command): container.id, interactive=True, logs=True, - raw=True + raw=tty ) as c: service.start_container(container, ports=None) c.run()