From c9bf83b44dc5ed7d90aeb1a67f82797d7b08ea46 Mon Sep 17 00:00:00 2001 From: Adam Kirchberger Date: Mon, 18 Apr 2022 08:04:19 +0100 Subject: [PATCH] fix: show matched hosts when applying --- nectl/configs/cli.py | 5 ++++- nectl/datatree/hosts.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nectl/configs/cli.py b/nectl/configs/cli.py index dea2796..7dafb36 100644 --- a/nectl/configs/cli.py +++ b/nectl/configs/cli.py @@ -171,9 +171,12 @@ def apply_cmd( print(f"Error: {e}") sys.exit(1) + print("Applying config to:") + print("\n".join([f"- {host.id}" for host in hosts])) + if not assumeyes: click.confirm( - f"Are you sure you want to modify {len(hosts)} live hosts?", abort=True + f"\nAre you sure you want to modify {len(hosts)} live hosts?", abort=True ) sys.exit( diff --git a/nectl/datatree/hosts.py b/nectl/datatree/hosts.py index c027731..7681190 100644 --- a/nectl/datatree/hosts.py +++ b/nectl/datatree/hosts.py @@ -214,7 +214,10 @@ def is_match(host: Host) -> bool: # Add host hosts.append(host) - logger.info(f"hosts after filter: {len(hosts)}") + logger.info( + f"filter matched {len(hosts)} hosts: " + f"{','.join([host.id for host in hosts])}" + ) if len(hosts) == 0: print("No hosts found.", file=sys.stderr)