aides-spec/aides_spec/commands/create.py

35 lines
1 KiB
Python
Raw Normal View History

2025-01-02 21:26:20 +00:00
import sys
from typing import Annotated, Optional
import typer
from aides_spec.utils.from_pkgbuild import (
create_from_pkgbuild,
download_pkgbuild,
)
app = typer.Typer()
@app.command()
def create(
from_aur: Annotated[Optional[str], typer.Option()] = None,
from_pkgbuild: Annotated[Optional[str], typer.Option()] = None,
output_file: Annotated[str, typer.Option("--output", "-o")] = "alr.sh",
):
if from_aur:
print(f"Загружаем PKGBUILD для пакета '{from_aur}' из AUR...")
content = download_pkgbuild(from_aur)
create_from_pkgbuild(content, output_file)
elif from_pkgbuild:
print(f"Читаем PKGBUILD из локального файла '{from_pkgbuild}'...")
try:
with open(from_pkgbuild, "rb") as f:
content = f.read()
create_from_pkgbuild(content, output_file)
except IOError as e:
print(f"Ошибка чтения файла '{from_pkgbuild}': {e}")
sys.exit(1)
else:
sys.exit(1)