瀏覽代碼

Add option to disable pseudo-tty on fig run

Also disable tty if stdin is not a tty.
Ben Firshman 11 年之前
父節點
當前提交
fc1bbb45b1
共有 1 個文件被更改,包括 11 次插入4 次删除
  1. 11 4
      fig/cli/main.py

+ 11 - 4
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()