Skip to content

Commit 328c4c7

Browse files
author
PyCompiler ARK++
committed
connection de only mod de bcasl
1 parent 8a71879 commit 328c4c7

3 files changed

Lines changed: 29 additions & 11 deletions

File tree

bcasl/only_mod/app.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ def _apply_theme(app: QApplication) -> None:
4141
pass
4242

4343

44-
def run(argv: list[str]) -> int:
44+
def run(theme: str = None) -> int:
4545
# Minimal environment sanity
4646
os.environ.setdefault("PYTHONUTF8", "1")
4747
os.environ.setdefault("PYTHONIOENCODING", "utf-8")
4848

49-
app = QApplication(argv)
49+
if theme:
50+
os.environ["BCASL_THEME"] = theme
51+
52+
app = QApplication([])
5053
app.setApplicationName(APP_NAME)
5154
# Try to reuse repo logo if present
5255
try:

bcasl/only_mod/main.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,21 @@
22
from __future__ import annotations
33

44
import sys
5-
from .app import run
65

6+
try:
7+
import click
78

8-
if __name__ == "__main__":
9-
sys.exit(run(sys.argv))
9+
@click.command()
10+
@click.option("--theme", default=None, help="Theme file to use")
11+
def main(theme):
12+
from .app import run
13+
sys.exit(run(theme))
14+
15+
if __name__ == "__main__":
16+
main()
17+
18+
except ImportError:
19+
from .app import run
20+
21+
if __name__ == "__main__":
22+
sys.exit(run())

main.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -460,31 +460,33 @@ def _launch_main():
460460

461461
@click.group(invoke_without_command=True, context_settings={"help_option_names": ["-h", "--help"]})
462462
@click.option("--bcasl-only", is_flag=True, help="Launch BCASL Studio (Standalone)")
463+
@click.option("--theme", default=None, help="Theme file for BCASL Studio")
463464
@click.pass_context
464-
def cli(ctx: click.Context, bcasl_only: bool):
465+
def cli(ctx: click.Context, bcasl_only: bool, theme: str):
465466
"""PyCompiler ARK++ CLI."""
466467
if ctx.invoked_subcommand is None:
467468
if bcasl_only:
468469
from bcasl.only_mod.app import run as run_bcasl
469-
rc = run_bcasl(sys.argv)
470+
rc = run_bcasl(theme)
470471
raise SystemExit(rc)
471472
else:
472-
rc = main(sys.argv)
473+
rc = main([sys.argv[0]] + list(ctx.args))
473474
raise SystemExit(rc)
474475

475476
@cli.command(name="bcasl")
476-
def cli_bcasl():
477+
@click.option("--theme", default=None, help="Theme file to use")
478+
def cli_bcasl(theme):
477479
"""Launch BCASL Studio (Standalone)."""
478480
from bcasl.only_mod.app import run as run_bcasl
479-
rc = run_bcasl(sys.argv)
481+
rc = run_bcasl(theme)
480482
raise SystemExit(rc)
481483

482484
except Exception:
483485
# Fallback CLI if click isn't available
484486
def cli(): # type: ignore
485487
if any(arg in ("--bcasl-only", "bcasl") for arg in sys.argv[1:]):
486488
from bcasl.only_mod.app import run as run_bcasl
487-
rc = run_bcasl(sys.argv)
489+
rc = run_bcasl()
488490
raise SystemExit(rc)
489491
rc = main(sys.argv)
490492
raise SystemExit(rc)

0 commit comments

Comments
 (0)