1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-25 14:03:00 +00:00
kiwi-scp/kiwi_scp/subcommands/new.py

31 lines
837 B
Python
Raw Normal View History

2020-08-18 13:56:58 +00:00
# system
import logging
import os
import shutil
# local
from .._constants import DEFAULT_DOCKER_COMPOSE_NAME
2020-08-19 15:21:38 +00:00
from ..subcommand import ProjectCommand
2020-08-18 13:56:58 +00:00
class NewCommand(ProjectCommand):
"""kiwi new"""
def __init__(self):
super().__init__(
'new', num_projects='+',
action="Creating",
2020-08-18 13:56:58 +00:00
description="Create new empty project(s) in this instance"
)
def _run_project(self, runner, args, project):
if project.exists():
logging.error(f"Project '{project.get_name()}' exists in this instance!")
return False
else:
os.mkdir(project.disabled_dir_name())
shutil.copy(DEFAULT_DOCKER_COMPOSE_NAME, project.compose_file_name())
logging.debug(f"Project '{project.get_name()}' created")
return True