You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
parser.add_argument('--nocleanup', action='store_true', help='do not remove the docker container when stopped')
38
42
parser.add_argument('--persist-image', action='store_true', help='do not remove the docker image when stopped', default=False) #TODO(tfoote) Add a name to it if persisting
@@ -56,6 +60,34 @@ def main():
56
60
args_dict['mode'] =OPERATIONS_DRY_RUN
57
61
print('DEPRECATION Warning: --noexecute is deprecated for --mode dry-run please switch your usage by December 2020')
58
62
63
+
# validate_operating_mode
64
+
operating_mode=args_dict.get('mode')
65
+
# Don't try to be interactive if there's no tty
66
+
ifnotos.isatty(sys.__stdin__.fileno()):
67
+
ifoperating_mode==OPERATIONS_INTERACTIVE:
68
+
parser.error("No tty detected cannot operate in interactive mode")
69
+
elifnotoperating_mode:
70
+
print("No tty detected for stdin defaulting mode to non-interactive")
71
+
args_dict['mode'] =OPERATIONS_NON_INTERACTIVE
72
+
73
+
# Check if detach extension is active and deconflict with interactive
74
+
detach_active=args_dict.get('detach')
75
+
operating_mode=args_dict.get('mode')
76
+
ifdetach_active:
77
+
ifoperating_mode==OPERATIONS_INTERACTIVE:
78
+
parser.error("Command line option --mode=interactive and --detach are mutually exclusive")
79
+
elifnotoperating_mode:
80
+
print(f"Detach extension active, defaulting mode to {OPERATIONS_NON_INTERACTIVE}")
81
+
args_dict['mode'] =OPERATIONS_NON_INTERACTIVE
82
+
# TODO(tfoote) Deal with the case of dry-run + detach
83
+
# Right now the printed results will include '-it'
84
+
# But based on testing the --detach overrides -it in docker so it's ok.
0 commit comments