Added workspace handling for new command

This commit is contained in:
2021-04-08 20:58:55 +02:00
parent 0f836b5c7d
commit fc53f90ecd
10 changed files with 101 additions and 81 deletions

View File

@@ -1,25 +0,0 @@
# -*- coding: utf-8 -*-
"""
sh_cpl-cli sh-edraft Common Python library CLI
~~~~~~~~~~~~~~~~~~~
sh-edraft Common Python library Command Line Interface
:copyright: (c) 2020 - 2021 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'cpl_cli.templates.new.library.cli'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='None')

View File

@@ -1,29 +0,0 @@
import textwrap
from cpl.utils.string import String
from cpl_cli.templates.template_file_abc import TemplateFileABC
class CLIInitTemplate(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}_cli/'
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

View File

@@ -11,7 +11,7 @@ class ApplicationTemplate(TemplateFileABC):
name = String.convert_to_snake_case(name)
self._name = 'application.py'
self._path = f'src/{name}_cli/'
self._path = f'src/{name}/'
self._value = textwrap.dedent("""\
from cpl.application import ApplicationABC
from cpl.configuration import ConfigurationABC

View File

@@ -1,13 +1,15 @@
import textwrap
from cpl.utils.string import String
from cpl_cli.templates.template_file_abc import TemplateFileABC
class TestsInitTemplate(TemplateFileABC):
class NameInitTemplate(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("""\

View File

@@ -11,12 +11,12 @@ class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
name = String.convert_to_snake_case(name)
self._name = 'main.py'
self._path = f'src/{name}_cli/'
self._path = f'src/{name}/'
self._value = textwrap.dedent(f"""\
from cpl.application import ApplicationBuilder
from {name}_cli.application import Application
from {name}_cli.startup import Startup
from {name}.application import Application
from {name}.startup import Startup
def main():
@@ -44,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(f"""\
from cpl.application import ApplicationBuilder
from {name}_cli.application import Application
from {name}.application import Application
def main():

View File

@@ -11,7 +11,7 @@ class StartupTemplate(TemplateFileABC):
name = String.convert_to_snake_case(name)
self._name = 'startup.py'
self._path = f'src/{name}_cli/'
self._path = f'src/{name}/'
self._value = textwrap.dedent("""\
from cpl.application import StartupABC
from cpl.configuration import ConfigurationABC