Implement template conflict checks and file copying in cmd_init function
This commit is contained in:
parent
d9dd069d50
commit
7ac20ea8b4
@ -1,4 +1,5 @@
|
|||||||
from .cli import CLI
|
from .cli import CLI
|
||||||
|
from .commands.setup import is_nut_workspace, find_template_conflicts, copy_template_files
|
||||||
|
|
||||||
def help_text():
|
def help_text():
|
||||||
return [
|
return [
|
||||||
@ -29,7 +30,20 @@ def main() -> int:
|
|||||||
return cli.run()
|
return cli.run()
|
||||||
|
|
||||||
def cmd_init(args, flags) -> int:
|
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
|
return 0
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
0
nut/commands/__init__.py
Normal file
0
nut/commands/__init__.py
Normal file
Loading…
x
Reference in New Issue
Block a user