readmes and mds plus fixed ruff
This commit is contained in:
@@ -7,7 +7,7 @@ import click
|
||||
|
||||
from . import __version__
|
||||
from .errors import activate
|
||||
from .transpiler import transpile_file, run_transpiled
|
||||
from .transpiler import run_transpiled, transpile_file
|
||||
|
||||
|
||||
@click.group()
|
||||
@@ -20,7 +20,7 @@ def main():
|
||||
@main.command()
|
||||
@click.argument("file", type=click.Path(exists=True, path_type=Path))
|
||||
@click.option("--lang", "-l", default=None, help="Override language code (e.g. es, ta)")
|
||||
@click.option("--keep", is_flag=True, help="Keep the compiled .py file alongside the source")
|
||||
@click.option("--keep", is_flag=True, help="Keep the compiled .py alongside the source")
|
||||
def run(file: Path, lang: str | None, keep: bool):
|
||||
"""Transpile and run a foreign-language Python file."""
|
||||
if lang:
|
||||
@@ -44,12 +44,15 @@ def run(file: Path, lang: str | None, keep: bool):
|
||||
|
||||
@main.command()
|
||||
@click.argument("file", type=click.Path(exists=True, path_type=Path))
|
||||
@click.option("--output", "-o", default=None, help="Output path (default: same dir as source)")
|
||||
@click.option("--output", "-o", default=None, help="Output path (default: beside source)")
|
||||
def compile(file: Path, output: str | None):
|
||||
"""Transpile a file to standard Python without running it."""
|
||||
transpiled = transpile_file(file)
|
||||
|
||||
out_path = Path(output) if output else file.with_suffix("").with_suffix(".compiled.py")
|
||||
out_path = (
|
||||
Path(output) if output
|
||||
else file.with_suffix("").with_suffix(".compiled.py")
|
||||
)
|
||||
out_path.write_text(transpiled, encoding="utf-8")
|
||||
click.echo(f"Compiled: {out_path}")
|
||||
|
||||
@@ -77,6 +80,7 @@ def check(file: Path):
|
||||
def validate_pack(json_file: Path):
|
||||
"""Validate a language pack JSON file."""
|
||||
import json
|
||||
|
||||
from .pack import REQUIRED_SECTIONS
|
||||
|
||||
with open(json_file, encoding="utf-8") as f:
|
||||
|
||||
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from .pack import load_pack, PackNotFoundError
|
||||
from .pack import PackNotFoundError, load_pack
|
||||
|
||||
_active_lang: str | None = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user