Merge pull request 'feat/list-langs' (#4) from feat/list-langs into develop
Reviewed-on: KeshavAnandCode/foreign-thon#4
This commit is contained in:
@@ -6,10 +6,10 @@ ForeignThon transpiles `.es.py`, `.ta.py` (and more) into standard Python. Keywo
|
||||
|
||||
```python
|
||||
# hola.es.py
|
||||
definir saludar(nombre):
|
||||
def saludar(nombre):
|
||||
retornar f"Hola, {nombre}!"
|
||||
|
||||
para i en rango(3):
|
||||
para i en dist(3):
|
||||
imprimir(saludar(f"mundo {i}"))
|
||||
```
|
||||
|
||||
|
||||
@@ -274,7 +274,25 @@ def check(file: Path):
|
||||
click.echo(f"✗ {e}", err=True)
|
||||
sys.exit(1)
|
||||
|
||||
@main.command(context_settings=CONTEXT_SETTINGS)
|
||||
def langs():
|
||||
"""List all installed language packs."""
|
||||
from .pack import _discover_packs
|
||||
|
||||
packs = _discover_packs()
|
||||
if not packs:
|
||||
click.echo("No language packs installed.")
|
||||
click.echo("Try: pip install foreignthon-es")
|
||||
return
|
||||
|
||||
click.echo("Installed language packs:")
|
||||
for code, module in sorted(packs.items()):
|
||||
import json
|
||||
data = json.loads(module.get_pack_path().read_text(encoding="utf-8"))
|
||||
name = data["meta"].get("name", code)
|
||||
native = data["meta"].get("native_name", "")
|
||||
click.echo(f" {code:<6} {name} ({native})")
|
||||
|
||||
@main.command("pack", context_settings=CONTEXT_SETTINGS)
|
||||
@click.argument("json_file", type=click.Path(exists=True, path_type=Path))
|
||||
def validate_pack(json_file: Path):
|
||||
|
||||
Reference in New Issue
Block a user