|
1 | | -def run_repl(): |
| 1 | +def run_repl(banner='yes', quiet=False, history_file='yes', preamble=None): |
2 | 2 | import os |
3 | 3 | os.environ.setdefault("PYTHON_JULIACALL_HANDLE_SIGNALS", "yes") |
4 | 4 | if os.environ.get("PYTHON_JULIACALL_HANDLE_SIGNALS") != "yes": |
5 | 5 | print("Experimental JuliaCall REPL requires PYTHON_JULIACALL_HANDLE_SIGNALS=yes") |
6 | 6 | exit(1) |
7 | 7 |
|
8 | | - import argparse |
9 | | - from pathlib import Path |
10 | | - parser = argparse.ArgumentParser("JuliaCall REPL (experimental)") |
11 | | - parser.add_argument('--banner', choices=['yes', 'no', 'short'], default='yes', help='Enable or disable startup banner') |
12 | | - parser.add_argument('--quiet', '-q', action='store_true', help='Quiet startup: no banner, suppress REPL warnings') |
13 | | - parser.add_argument('--history-file', choices=['yes', 'no'], default='yes', help='Load or save history') |
14 | | - parser.add_argument('--preamble', type=Path, help='Code to be included before the REPL starts') |
15 | | - args = parser.parse_args() |
16 | | - |
17 | 8 | from juliacall import Main, Base |
18 | 9 |
|
19 | 10 | Base.is_interactive = True |
20 | 11 |
|
21 | | - if not args.quiet: |
| 12 | + if not quiet: |
22 | 13 | Main.include(os.path.join(os.path.dirname(__file__), 'banner.jl')) |
23 | | - Main.__PythonCall_banner(Base.Symbol(args.banner)) |
| 14 | + Main.__PythonCall_banner(Base.Symbol(banner)) |
24 | 15 |
|
25 | 16 | if Main.seval(r'VERSION > v"v1.11.0-alpha1"'): |
26 | 17 | no_banner_opt = Base.Symbol("no") |
27 | 18 | else: |
28 | 19 | no_banner_opt = False |
29 | 20 |
|
30 | | - if args.preamble: |
31 | | - Main.include(str(args.preamble.resolve())) |
| 21 | + if preamble: |
| 22 | + Main.include(str(preamble.resolve())) |
32 | 23 |
|
33 | 24 | Base.run_main_repl( |
34 | 25 | Base.is_interactive, |
35 | | - args.quiet, |
| 26 | + quiet, |
36 | 27 | no_banner_opt, |
37 | | - args.history_file == 'yes', |
| 28 | + history_file == 'yes', |
38 | 29 | True |
39 | 30 | ) |
40 | 31 |
|
|
0 commit comments