Improved workspace handling to new command for console type

This commit is contained in:
2021-04-09 22:41:04 +02:00
parent 167f813bcf
commit 2b5c75cc67
6 changed files with 84 additions and 47 deletions

View File

@@ -1,3 +1,4 @@
import os.path
import textwrap
from cpl.utils.string import String
@@ -6,12 +7,12 @@ from cpl_cli.templates.template_file_abc import TemplateFileABC
class ApplicationTemplate(TemplateFileABC):
def __init__(self, name: str):
def __init__(self, name: str, path: str):
TemplateFileABC.__init__(self)
name = String.convert_to_snake_case(name)
self._name = 'application.py'
self._path = f'src/{name}/'
self._path = os.path.join(path, name)
self._value = textwrap.dedent("""\
from cpl.application import ApplicationABC
from cpl.configuration import ConfigurationABC

View File

@@ -1,3 +1,4 @@
import os.path
import textwrap
from cpl.utils.string import String
@@ -6,12 +7,12 @@ from cpl_cli.templates.template_file_abc import TemplateFileABC
class MainInitTemplate(TemplateFileABC):
def __init__(self, name: str):
def __init__(self, name: str, path: str):
TemplateFileABC.__init__(self)
name = String.convert_to_snake_case(name)
self._name = '__init__.py'
self._path = f'src/{name}/'
self._path = os.path.join(path, name)
self._value = textwrap.dedent("""\
# imports:
""")

View File

@@ -1,3 +1,4 @@
import os.path
import textwrap
from cpl.utils.string import String
@@ -6,12 +7,12 @@ from cpl_cli.templates.template_file_abc import TemplateFileABC
class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
def __init__(self, name: str):
def __init__(self, name: str, path: str):
TemplateFileABC.__init__(self)
name = String.convert_to_snake_case(name)
self._name = 'main.py'
self._path = f'src/{name}/'
self._path = os.path.join(path, name)
self._value = textwrap.dedent(f"""\
from cpl.application import ApplicationBuilder
@@ -44,12 +45,12 @@ class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
class MainWithApplicationBaseTemplate(TemplateFileABC):
def __init__(self, name: str):
def __init__(self, name: str, path: str):
TemplateFileABC.__init__(self)
name = String.convert_to_snake_case(name)
self._name = 'main.py'
self._path = f'src/{name}'
self._path = os.path.join(path, name)
self._value = textwrap.dedent(f"""\
from cpl.application import ApplicationBuilder
@@ -80,12 +81,12 @@ class MainWithApplicationBaseTemplate(TemplateFileABC):
class MainWithoutApplicationBaseTemplate(TemplateFileABC):
def __init__(self, name: str):
def __init__(self, name: str, path: str):
TemplateFileABC.__init__(self)
name = String.convert_to_snake_case(name)
self._name = 'main.py'
self._path = f'src/{name}'
self._path = os.path.join(path, name)
self._value = textwrap.dedent("""\
from cpl.console import Console
@@ -113,12 +114,12 @@ class MainWithoutApplicationBaseTemplate(TemplateFileABC):
class MainWithDependencyInjection(TemplateFileABC):
def __init__(self, name: str):
def __init__(self, name: str, path: str):
TemplateFileABC.__init__(self)
name = String.convert_to_snake_case(name)
self._name = 'main.py'
self._path = f'src/{name}'
self._path = os.path.join(path, name)
self._value = textwrap.dedent("""\
from cpl.configuration import Configuration, ConfigurationABC
from cpl.console import Console

View File

@@ -1,3 +1,4 @@
import os.path
import textwrap
from cpl.utils.string import String
@@ -6,12 +7,12 @@ from cpl_cli.templates.template_file_abc import TemplateFileABC
class StartupTemplate(TemplateFileABC):
def __init__(self, name: str):
def __init__(self, name: str, path: str):
TemplateFileABC.__init__(self)
name = String.convert_to_snake_case(name)
self._name = 'startup.py'
self._path = f'src/{name}/'
self._path = os.path.join(path, name)
self._value = textwrap.dedent("""\
from cpl.application import StartupABC
from cpl.configuration import ConfigurationABC