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