Another bulk of refaktoring cleanup

This commit is contained in:
2025-07-11 18:57:40 +02:00
parent 168c5c0da6
commit 33276263b0
12 changed files with 210 additions and 56 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
CLI for extracting invokable role paths from a nested roles YAML file using argparse.
CLI for extracting invokable or non-invokable role paths from a nested roles YAML file using argparse.
Assumes a default roles file at the project root if none is provided.
"""
@@ -18,12 +18,12 @@ sys.path.insert(0, project_root)
import argparse
import yaml
from filter_plugins.invokable_paths import get_invokable_paths
from filter_plugins.invokable_paths import get_invokable_paths, get_non_invokable_paths
def main():
parser = argparse.ArgumentParser(
description="Extract invokable role paths from a nested roles YAML file."
description="Extract invokable or non-invokable role paths from a nested roles YAML file."
)
parser.add_argument(
"roles_file",
@@ -33,13 +33,33 @@ def main():
)
parser.add_argument(
"--suffix", "-s",
help="Optional suffix to append to each invokable path.",
help="Optional suffix to append to each path.",
default=None
)
mode_group = parser.add_mutually_exclusive_group()
mode_group.add_argument(
"--non-invokable", "-n",
action='store_true',
help="List paths where 'invokable' is False or not set."
)
mode_group.add_argument(
"--invokable", "-i",
action='store_true',
help="List paths where 'invokable' is True. (default behavior)"
)
args = parser.parse_args()
# Default to invokable if neither flag is provided
list_non = args.non_invokable
list_inv = args.invokable or not (args.non_invokable or args.invokable)
try:
paths = get_invokable_paths(args.roles_file, args.suffix)
if list_non:
paths = get_non_invokable_paths(args.roles_file, args.suffix)
else:
paths = get_invokable_paths(args.roles_file, args.suffix)
except FileNotFoundError as e:
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)
@@ -55,4 +75,4 @@ def main():
if __name__ == "__main__":
main()
main()