readmes and mds plus fixed ruff
This commit is contained in:
@@ -52,3 +52,7 @@ src = ["src"]
|
|||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
select = ["E", "F", "I"]
|
select = ["E", "F", "I"]
|
||||||
|
ignore = ["E501"]
|
||||||
|
|
||||||
|
[tool.ruff.lint.per-file-ignores]
|
||||||
|
"pack.py" = ["E501"]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import click
|
|||||||
|
|
||||||
from . import __version__
|
from . import __version__
|
||||||
from .errors import activate
|
from .errors import activate
|
||||||
from .transpiler import transpile_file, run_transpiled
|
from .transpiler import run_transpiled, transpile_file
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
@@ -20,7 +20,7 @@ def main():
|
|||||||
@main.command()
|
@main.command()
|
||||||
@click.argument("file", type=click.Path(exists=True, path_type=Path))
|
@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("--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):
|
def run(file: Path, lang: str | None, keep: bool):
|
||||||
"""Transpile and run a foreign-language Python file."""
|
"""Transpile and run a foreign-language Python file."""
|
||||||
if lang:
|
if lang:
|
||||||
@@ -44,12 +44,15 @@ def run(file: Path, lang: str | None, keep: bool):
|
|||||||
|
|
||||||
@main.command()
|
@main.command()
|
||||||
@click.argument("file", type=click.Path(exists=True, path_type=Path))
|
@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):
|
def compile(file: Path, output: str | None):
|
||||||
"""Transpile a file to standard Python without running it."""
|
"""Transpile a file to standard Python without running it."""
|
||||||
transpiled = transpile_file(file)
|
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")
|
out_path.write_text(transpiled, encoding="utf-8")
|
||||||
click.echo(f"Compiled: {out_path}")
|
click.echo(f"Compiled: {out_path}")
|
||||||
|
|
||||||
@@ -77,6 +80,7 @@ def check(file: Path):
|
|||||||
def validate_pack(json_file: Path):
|
def validate_pack(json_file: Path):
|
||||||
"""Validate a language pack JSON file."""
|
"""Validate a language pack JSON file."""
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from .pack import REQUIRED_SECTIONS
|
from .pack import REQUIRED_SECTIONS
|
||||||
|
|
||||||
with open(json_file, encoding="utf-8") as f:
|
with open(json_file, encoding="utf-8") as f:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from .pack import load_pack, PackNotFoundError
|
from .pack import PackNotFoundError, load_pack
|
||||||
|
|
||||||
_active_lang: str | None = None
|
_active_lang: str | None = None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user