Added shadow option to tree for mig

This commit is contained in:
2025-07-18 19:35:44 +02:00
parent d4fbdb409f
commit 45624037b1
9 changed files with 80 additions and 1 deletions

View File

@@ -45,6 +45,12 @@ def main():
action='store_true',
help="Preview graphs to console instead of writing files"
)
parser.add_argument(
'-s', '--shadow-folder',
type=str,
default=None,
help="If set, writes tree.json to this shadow folder instead of the role's actual meta/ folder"
)
parser.add_argument(
'-v', '--verbose',
action='store_true',
@@ -57,6 +63,7 @@ def main():
print(f"Max depth: {args.depth}")
print(f"Output format: {args.output}")
print(f"Preview mode: {args.preview}")
print(f"Shadow folder: {args.shadow_folder}")
for role_name, role_path in find_roles(args.role_dir):
if args.verbose:
@@ -74,7 +81,13 @@ def main():
print(f"Previewing graph '{key}' for role '{role_name}'")
output_graph(data, 'console', role_name, key)
else:
tree_file = os.path.join(role_path, 'meta', 'tree.json')
# Decide on output folder
if args.shadow_folder:
tree_file = os.path.join(
args.shadow_folder, role_name, 'meta', 'tree.json'
)
else:
tree_file = os.path.join(role_path, 'meta', 'tree.json')
os.makedirs(os.path.dirname(tree_file), exist_ok=True)
with open(tree_file, 'w') as f:
json.dump(graphs, f, indent=2)