Skip to content

Commit 846d823

Browse files
committed
Allow kwargs for juliacall.repl api
1 parent 972f47f commit 846d823

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

pysrc/juliacall/__main__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
if __name__ == '__main__':
22
import argparse
3-
from pathlib import Path
43
parser = argparse.ArgumentParser("JuliaCall REPL (experimental)")
54
parser.add_argument('-e', '--eval', type=str, default=None, help='Evaluate <expr>. If specified, all other arguments are ignored.')
65
parser.add_argument('-E', '--print', type=str, default=None, help='Evaluate <expr> and display the result. If specified, all other arguments are ignored.')
76

8-
parser.add_argument('--banner', choices=['yes', 'no', 'short'], default='yes', help='Enable or disable startup banner')
9-
parser.add_argument('--quiet', '-q', action='store_true', help='Quiet startup: no banner, suppress REPL warnings')
10-
parser.add_argument('--history-file', choices=['yes', 'no'], default='yes', help='Load or save history')
11-
parser.add_argument('--preamble', type=Path, help='Code to be included before the REPL starts')
7+
from juliacall.repl import add_repl_args
8+
add_repl_args(parser)
9+
1210
args = parser.parse_args()
1311
assert not (args.eval is not None and args.print is not None), "Cannot specify both -e/--eval and -E/--print"
12+
1413
if args.eval is not None:
1514
from juliacall import Main
1615
Main.seval(args.eval)

pysrc/juliacall/repl.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,17 @@ def run_repl(banner='yes', quiet=False, history_file='yes', preamble=None):
2929
True
3030
)
3131

32+
def add_repl_args(parser):
33+
from pathlib import Path
34+
parser.add_argument('--banner', choices=['yes', 'no', 'short'], default='yes', help='Enable or disable startup banner')
35+
parser.add_argument('--quiet', '-q', action='store_true', help='Quiet startup: no banner, suppress REPL warnings')
36+
parser.add_argument('--history-file', choices=['yes', 'no'], default='yes', help='Load or save history')
37+
parser.add_argument('--preamble', type=Path, help='Code to be included before the REPL starts')
38+
3239
if __name__ == '__main__':
33-
run_repl()
40+
import argparse
41+
parser = argparse.ArgumentParser("JuliaCall REPL (experimental)")
42+
from juliacall.repl import add_repl_args
43+
add_repl_args(parser)
44+
args = parser.parse_args()
45+
run_repl(args.banner, args.quiet, args.history_file, args.preamble)

0 commit comments

Comments
 (0)