mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-11-22 21:03:00 +00:00
36 lines
934 B
Python
36 lines
934 B
Python
# system
|
|
import logging
|
|
import os
|
|
import shutil
|
|
|
|
# local
|
|
from ._subcommand import ProjectCommand
|
|
|
|
# parent
|
|
from .._constants import DEFAULT_DOCKER_COMPOSE_NAME
|
|
|
|
|
|
class NewCommand(ProjectCommand):
|
|
"""kiwi new"""
|
|
|
|
def __init__(self):
|
|
super().__init__(
|
|
'new', num_projects='+',
|
|
action="Creating",
|
|
description="Create new empty project(s) in this instance"
|
|
)
|
|
|
|
def _run_projects(self, runner, args, projects):
|
|
result = True
|
|
|
|
for project in projects:
|
|
if project.exists():
|
|
logging.error(f"Project '{project.get_name()}' exists in this instance!")
|
|
result = False
|
|
|
|
else:
|
|
logging.info(f"Creating project '{project.get_name()}'")
|
|
os.mkdir(project.disabled_dir_name())
|
|
shutil.copy(DEFAULT_DOCKER_COMPOSE_NAME, project.compose_file_name())
|
|
|
|
return result
|