Skip to content

Commit 5070ea1

Browse files
committed
Add -E/--print
1 parent 6acaeba commit 5070ea1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pysrc/juliacall/__main__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
33
from pathlib import Path
44
parser = argparse.ArgumentParser("JuliaCall REPL (experimental)")
55
parser.add_argument('-e', '--eval', type=str, default=None, help='Evaluate <expr>. If specified, all other arguments are ignored.')
6+
parser.add_argument('-E', '--print', type=str, default=None, help='Evaluate <expr> and display the result. If specified, all other arguments are ignored.')
67

78
parser.add_argument('--banner', choices=['yes', 'no', 'short'], default='yes', help='Enable or disable startup banner')
89
parser.add_argument('--quiet', '-q', action='store_true', help='Quiet startup: no banner, suppress REPL warnings')
910
parser.add_argument('--history-file', choices=['yes', 'no'], default='yes', help='Load or save history')
1011
parser.add_argument('--preamble', type=Path, help='Code to be included before the REPL starts')
1112
args = parser.parse_args()
13+
assert not (args.eval is not None and args.print is not None)
1214
if args.eval is not None:
1315
from juliacall import Main
1416
Main.seval(args.eval)
17+
elif args.print is not None:
18+
from juliacall import Main
19+
result = Main.seval(args.print)
20+
Main.display(result)
1521
else:
1622
from juliacall.repl import run_repl
1723
run_repl(

0 commit comments

Comments
 (0)