Skip to content

Commit 5c39790

Browse files
Make script optional+pass everything to subprocess
This restores previous behaviour of the pythonSoftIOC executable, which would give you a Python command line interpreter.
1 parent a4e3f2f commit 5c39790

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

softioc/__main__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
def main(args=None):
1010
parser = ArgumentParser()
1111
parser.add_argument("--version", action="version", version=__version__)
12-
parser.add_argument("script", help="The python script to run")
12+
parser.add_argument(
13+
"script", help="The python script to run", nargs="?", default=None)
1314
parser.add_argument(
1415
"arg", help="Any arguments to pass to the script", nargs="*")
15-
parsed_args = parser.parse_args(args)
16-
# Execute as subprocess
17-
cmd = [sys.executable, parsed_args.script] + parsed_args.arg
16+
parsed_args, unknown = parser.parse_known_args(args)
17+
18+
# Execute as subprocess.
19+
cmd = [sys.executable] + parsed_args.arg + unknown
20+
if parsed_args.script:
21+
cmd.insert(1, parsed_args.script)
22+
1823
subprocess.Popen(cmd).communicate()
1924

2025

0 commit comments

Comments
 (0)