From 7ac20ea8b4dded8fc5536957e2057b8c2128ffcd Mon Sep 17 00:00:00 2001 From: lordlogo2002 Date: Fri, 3 Apr 2026 17:01:26 +0200 Subject: [PATCH] Implement template conflict checks and file copying in cmd_init function --- nut/__main__.py | 16 +++++++++++++++- nut/commands/__init__.py | 0 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 nut/commands/__init__.py diff --git a/nut/__main__.py b/nut/__main__.py index 9c95f1e..a76ba84 100644 --- a/nut/__main__.py +++ b/nut/__main__.py @@ -1,4 +1,5 @@ from .cli import CLI +from .commands.setup import is_nut_workspace, find_template_conflicts, copy_template_files def help_text(): return [ @@ -29,7 +30,20 @@ def main() -> int: return cli.run() def cmd_init(args, flags) -> int: - print("INIT", args, flags) + dest_dir = args[0] + force = flags["force"] + + conflicts = find_template_conflicts(dest_dir) + if conflicts and not force: + print("Some files already exist that would be overwritten:") + for file in conflicts: + print(f" {file}") + + print("Use --force to overwrite existing files.") + return 1 + + copy_template_files(dest_dir, force=force, checked=True) + return 0 if __name__ == "__main__": diff --git a/nut/commands/__init__.py b/nut/commands/__init__.py new file mode 100644 index 0000000..e69de29