Bugfixes for the command new
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
import textwrap
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class ApplicationTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, name: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'application.py'
|
||||
self._path = 'src/'
|
||||
self._path = f'src/{name}/'
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.application import ApplicationABC
|
||||
from cpl.configuration import ConfigurationABC
|
29
src/cpl_cli/templates/new/console/src/name/init.py
Normal file
29
src/cpl_cli/templates/new/console/src/name/init.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import textwrap
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class MainInitTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self, name: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = '__init__.py'
|
||||
self._path = f'src/{name}/'
|
||||
self._value = textwrap.dedent("""\
|
||||
# imports:
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
@@ -1,20 +1,22 @@
|
||||
import textwrap
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, name: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'main.py'
|
||||
self._path = 'src/'
|
||||
self._value = textwrap.dedent("""\
|
||||
self._path = f'src/{name}/'
|
||||
self._value = textwrap.dedent(f"""\
|
||||
from cpl.application import ApplicationBuilder
|
||||
|
||||
from application import Application
|
||||
from startup import Startup
|
||||
from {name}.application import Application
|
||||
from {name}.startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
@@ -42,15 +44,16 @@ class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
|
||||
|
||||
class MainWithApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, name: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'main.py'
|
||||
self._path = 'src/'
|
||||
self._value = textwrap.dedent("""\
|
||||
self._path = f'src/{name}'
|
||||
self._value = textwrap.dedent(f"""\
|
||||
from cpl.application import ApplicationBuilder
|
||||
|
||||
from application import Application
|
||||
from {name}.application import Application
|
||||
|
||||
|
||||
def main():
|
||||
@@ -77,11 +80,12 @@ class MainWithApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
class MainWithoutApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, name: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'main.py'
|
||||
self._path = 'src/'
|
||||
self._path = f'src/{name}'
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.console import Console
|
||||
|
||||
@@ -109,11 +113,12 @@ class MainWithoutApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
class MainWithDependencyInjection(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, name: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'main.py'
|
||||
self._path = 'src/'
|
||||
self._path = f'src/{name}'
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.configuration import Configuration, ConfigurationABC
|
||||
from cpl.console import Console
|
@@ -1,15 +1,17 @@
|
||||
import textwrap
|
||||
|
||||
from cpl.utils.string import String
|
||||
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||
|
||||
|
||||
class StartupTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, name: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
name = String.convert_to_snake_case(name)
|
||||
self._name = 'startup.py'
|
||||
self._path = 'src/'
|
||||
self._path = f'src/{name}/'
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.application import StartupABC
|
||||
from cpl.configuration import ConfigurationABC
|
@@ -47,7 +47,7 @@ class MainWithApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
self._name = 'main.py'
|
||||
self._path = 'src/'
|
||||
self._value = textwrap.dedent("""\
|
||||
self._value = textwrap.dedent(f"""\
|
||||
from cpl.application import ApplicationBuilder
|
||||
|
||||
from {name}_cli.application import Application
|
||||
|
Reference in New Issue
Block a user