@@ -91,6 +91,7 @@ def _cli_impl(
91
91
port : int = 0 ,
92
92
debug : bool = False ,
93
93
input_script : str = None ,
94
+ script_args : str = None ,
94
95
exe : str = None ,
95
96
version : int = None ,
96
97
graphical : bool = False ,
@@ -111,6 +112,9 @@ def _cli_impl(
111
112
if input_script :
112
113
raise Exception ("Cannot open in server mode with an input script." )
113
114
115
+ if not input_script and script_args :
116
+ raise Exception ("Cannot add script arguments without an input script." )
117
+
114
118
# If the input_script and port are missing in batch mode, raise an exception
115
119
if (not graphical ) and (input_script is None ) and (not port ):
116
120
raise Exception ("An input script, -i, or port, --port, are required in batch mode." )
@@ -142,6 +146,13 @@ def _cli_impl(
142
146
args .append ("-script" )
143
147
args .append (input_script )
144
148
149
+ if script_args :
150
+ args .append ("-ScriptArgs" )
151
+ if '"' in script_args :
152
+ args .append (f"'{ script_args } '" )
153
+ else :
154
+ args .append (f'"{ script_args } "' )
155
+
145
156
if (not graphical ) and input_script :
146
157
exit = True
147
158
if version < 241 :
@@ -179,6 +190,7 @@ def _cli_impl(
179
190
if DRY_RUN :
180
191
return args , env
181
192
else :
193
+ print (args )
182
194
_run (args , env , False , True )
183
195
184
196
if private_appdata :
@@ -218,6 +230,11 @@ def _cli_impl(
218
230
default = None ,
219
231
help = "Name of the input Python script. Cannot be mixed with -p" ,
220
232
)
233
+ @click .option (
234
+ "--script-args" ,
235
+ default = None ,
236
+ help = "Arguments to pass into the --input-script, -i. Can only be used with -i." ,
237
+ )
221
238
@click .option (
222
239
"--exit" ,
223
240
is_flag = True ,
@@ -261,6 +278,7 @@ def cli(
261
278
port : int ,
262
279
debug : bool ,
263
280
input_script : str ,
281
+ script_args : str ,
264
282
revision : int ,
265
283
graphical : bool ,
266
284
show_welcome_screen : bool ,
@@ -286,6 +304,7 @@ def cli(
286
304
port ,
287
305
debug ,
288
306
input_script ,
307
+ script_args ,
289
308
exe ,
290
309
version ,
291
310
graphical ,
0 commit comments