From 3cdd4ba8b57ed95f63be70860b009b518ee08d79 Mon Sep 17 00:00:00 2001 From: June Date: Thu, 6 Jun 2024 21:08:38 +0200 Subject: [PATCH] update!: switch from one comma-sep. argument to variadic args. for hosts Since the hosts are what nixos-rebuild acts on it makes to have them represented by unlimited variadic arguments similar to how "git add", "cat", "nix build", etc. work. --- src/infra_rebuild/cli/__init__.py | 14 +++++++------- src/infra_rebuild/operations/__init__.py | 3 +-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/infra_rebuild/cli/__init__.py b/src/infra_rebuild/cli/__init__.py index fac2d3f..38030ea 100644 --- a/src/infra_rebuild/cli/__init__.py +++ b/src/infra_rebuild/cli/__init__.py @@ -10,42 +10,42 @@ def infra_rebuild(): @infra_rebuild.command() -@click.argument("hosts") +@click.argument("hosts", nargs=-1) def build(hosts): operations.run("build", hosts) @infra_rebuild.command() -@click.argument("hosts") +@click.argument("hosts", nargs=-1) def build_vm(hosts): operations.run("build-vm", hosts) @infra_rebuild.command() -@click.argument("hosts") +@click.argument("hosts", nargs=-1) def build_vm_with_bootloader(hosts): operations.run("build-vm-with-bootloader", hosts) @infra_rebuild.command() -@click.argument("hosts") +@click.argument("hosts", nargs=-1) def switch(hosts): operations.run("switch", hosts) @infra_rebuild.command() -@click.argument("hosts") +@click.argument("hosts", nargs=-1) def boot(hosts): operations.run("boot", hosts) @infra_rebuild.command() -@click.argument("hosts") +@click.argument("hosts", nargs=-1) def test(hosts): operations.run("test", hosts) @infra_rebuild.command() -@click.argument("hosts") +@click.argument("hosts", nargs=-1) def reboot(hosts): operations.run("reboot", hosts) diff --git a/src/infra_rebuild/operations/__init__.py b/src/infra_rebuild/operations/__init__.py index 4a581e0..0ae726e 100644 --- a/src/infra_rebuild/operations/__init__.py +++ b/src/infra_rebuild/operations/__init__.py @@ -23,8 +23,7 @@ def run(operation, hosts): msg.error("Internal Error: The given operation isn't valid.") sys.exit(1) - for host_string in hosts.split(","): - host = host_string.strip() + for host in hosts: if not host: msg.warning("Skipping empty string provided for host.") continue