transip-client/transip_client/cli.py
sonny 4dad8eb1e7
All checks were successful
ci/woodpecker/push/tests Pipeline was successful
Update command name
2025-05-03 14:39:13 +02:00

40 lines
943 B
Python

from pathlib import Path
import click
from transip_client.main import detect
@click.command()
@click.argument("login")
@click.argument("private-key-path")
@click.argument("domains", nargs=-1)
@click.option(
"--adapter-class",
default="transip_client.adapters.OpenDNSAdapter",
)
@click.option("--read-only/--write", default=False)
def update(
domains: list[str],
login: str,
private_key_path: str,
adapter_class: str,
read_only: bool,
) -> None:
if not domains:
raise ValueError("No domain(s) specified")
if not Path(private_key_path).exists():
raise ValueError(f"Unknown private key path: {private_key_path}")
if not all((login, private_key_path)):
raise ValueError(
"Both a login name and the path to a private key need to be specified"
)
detect(
domains,
(private_key_path, login),
adapter_class,
read_only,
)