Improved new command to use workspace when found
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
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
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
import textwrap
|
||||
|
||||
from cpl.utils.string import String
|
||||
@@ -6,12 +7,12 @@ from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||
|
||||
class NameInitTemplate(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:
|
||||
""")
|
||||
|
@@ -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 = 'src/'
|
||||
self._path = os.path.join(path, name)
|
||||
self._value = textwrap.dedent(f"""\
|
||||
from cpl.application import ApplicationBuilder
|
||||
|
||||
@@ -80,11 +81,11 @@ class MainWithApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
class MainWithoutApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = 'main.py'
|
||||
self._path = 'src/'
|
||||
self._path = os.path.join(path, name)
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.console import Console
|
||||
|
||||
@@ -112,11 +113,11 @@ class MainWithoutApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
class MainWithDependencyInjection(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, name: str, path: str):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = 'main.py'
|
||||
self._path = 'src/'
|
||||
self._path = os.path.join(path, name)
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.configuration import Configuration, ConfigurationABC
|
||||
from cpl.console import Console
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
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
|
||||
|
Reference in New Issue
Block a user