2025-01-02 21:26:20 +00:00
|
|
|
import sys
|
|
|
|
from typing import Annotated, Optional
|
|
|
|
|
|
|
|
import typer
|
|
|
|
|
2025-01-05 08:37:11 +00:00
|
|
|
from aides_spec.utils.empty_template import create_from_empty_template
|
2025-01-02 21:26:20 +00:00
|
|
|
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,
|
2025-01-05 08:37:11 +00:00
|
|
|
empty_template: Annotated[Optional[bool], typer.Option()] = None,
|
2025-01-02 21:26:20 +00:00
|
|
|
):
|
2025-01-05 08:37:11 +00:00
|
|
|
output_file = "alr.sh"
|
|
|
|
|
|
|
|
if empty_template:
|
|
|
|
create_from_empty_template(output_file)
|
|
|
|
elif from_aur:
|
2025-01-02 21:26:20 +00:00
|
|
|
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)
|