Skip to content

Commit

Permalink
do not allow the user to specify both
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsochat@stanford.edu>
  • Loading branch information
vsoch committed Jan 5, 2021
1 parent 8fa2064 commit 75e5c83
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/spack/spack/cmd/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def python(parser, args, unknown_args):
if unknown_args:
tty.die("Unknown arguments:", " ".join(unknown_args))

# Unexpected behavior from supplying both
if args.python_command and args.python_args:
tty.die("You can only specify a command OR script, but not both.")

# Run user choice of interpreter
if args.python_interpreter == "ipython":
return spack.cmd.python.ipython_interpreter(args)
Expand All @@ -73,9 +77,7 @@ def ipython_interpreter(args):
exec(startup.read())

# IPython can also support running a script OR command, not both
if args.python_command and args.python_args:
tty.die("ipython only supports a script OR command with -c, not both.")
elif args.python_args:
if args.python_args:
IPython.start_ipython(argv=args.python_args)
elif args.python_command:
IPython.start_ipython(argv=['-c', args.python_command])
Expand Down

0 comments on commit 75e5c83

Please sign in to comment.