fixed langs cli, changed init to auto track version
This commit is contained in:
@@ -1 +1,7 @@
|
||||
__version__ = "0.1.0"
|
||||
from importlib.metadata import version, PackageNotFoundError
|
||||
|
||||
try:
|
||||
__version__ = version("foreignthon")
|
||||
except PackageNotFoundError:
|
||||
# Fallback for local editable development or running scripts directly
|
||||
__version__ = "0.0.0"
|
||||
@@ -290,7 +290,8 @@ def check(files: tuple):
|
||||
|
||||
@main.command(context_settings=CONTEXT_SETTINGS)
|
||||
def langs():
|
||||
"""List all installed language packs."""
|
||||
"""List all installed language packs with their versions and authors."""
|
||||
import json
|
||||
from .pack import _discover_packs
|
||||
|
||||
packs = _discover_packs()
|
||||
@@ -301,12 +302,22 @@ def langs():
|
||||
|
||||
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})")
|
||||
|
||||
# 1. Dynamically read python package attributes from the discovered module
|
||||
ver = getattr(module, "__version__", "unknown")
|
||||
authors_list = getattr(module, "__authors__", [])
|
||||
authors_str = f" by {', '.join(authors_list)}" if authors_list else ""
|
||||
|
||||
# 2. Safely read the underlying JSON for layout/display names
|
||||
try:
|
||||
data = json.loads(module.get_pack_path().read_text(encoding="utf-8"))
|
||||
name = data["meta"].get("name", code)
|
||||
native = data["meta"].get("native_name", "")
|
||||
except Exception:
|
||||
name, native = code, ""
|
||||
|
||||
# 3. Print a unified, professional summary line
|
||||
click.echo(f" {code:<6} {name} ({native}) v{ver}{authors_str}")
|
||||
|
||||
@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