Bugfixes
This commit is contained in:
parent
7af7f866c1
commit
05b9fd801b
@ -25,18 +25,17 @@ class ServiceProvider(ServiceProviderABC):
|
||||
|
||||
return None
|
||||
|
||||
def _get_service(self, service_type: type, parameter: Parameter) -> object:
|
||||
def _get_service(self, parameter: Parameter) -> object:
|
||||
for descriptor in self._service_descriptors:
|
||||
if descriptor.service_type == parameter.annotation or issubclass(descriptor.service_type,
|
||||
parameter.annotation):
|
||||
if descriptor.service_type == parameter.annotation or issubclass(descriptor.service_type, parameter.annotation):
|
||||
if descriptor.implementation is not None:
|
||||
return descriptor.implementation
|
||||
|
||||
implementation = self.build_service(service_type)
|
||||
implementation = self.build_service(descriptor.service_type)
|
||||
if descriptor.lifetime == ServiceLifetimeEnum.singleton:
|
||||
descriptor.implementation = implementation
|
||||
|
||||
return descriptor.implementation
|
||||
return implementation
|
||||
|
||||
def build_service(self, service_type: type) -> object:
|
||||
for descriptor in self._service_descriptors:
|
||||
@ -69,7 +68,7 @@ class ServiceProvider(ServiceProviderABC):
|
||||
params.append(self._configuration)
|
||||
|
||||
else:
|
||||
params.append(self._get_service(service_type, parameter))
|
||||
params.append(self._get_service(parameter))
|
||||
|
||||
return service_type(*params)
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
import os
|
||||
from collections import Callable
|
||||
|
||||
from cpl.application.application_abc import ApplicationRuntimeABC
|
||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||
from cpl.console.foreground_color_enum import ForegroundColorEnum
|
||||
from cpl.console.console import Console
|
||||
@ -18,11 +17,10 @@ from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||
|
||||
class GenerateService(CommandABC):
|
||||
|
||||
def __init__(self, configuration: ConfigurationABC, runtime: ApplicationRuntimeABC):
|
||||
def __init__(self, configuration: ConfigurationABC):
|
||||
"""
|
||||
Service for the CLI command generate
|
||||
:param configuration:
|
||||
:param runtime:
|
||||
"""
|
||||
CommandABC.__init__(self)
|
||||
|
||||
@ -54,7 +52,7 @@ class GenerateService(CommandABC):
|
||||
}
|
||||
|
||||
self._config = configuration
|
||||
self._runtime = runtime
|
||||
self._env = self._config.environment
|
||||
|
||||
@staticmethod
|
||||
def _help(message: str):
|
||||
@ -105,7 +103,7 @@ class GenerateService(CommandABC):
|
||||
|
||||
template = template(class_name, schematic, self._schematics[schematic]["Upper"], rel_path)
|
||||
|
||||
file_path = os.path.join(self._runtime.working_directory, template.path, template.name)
|
||||
file_path = os.path.join(self._env.working_directory, template.path, template.name)
|
||||
if not os.path.isdir(os.path.dirname(file_path)):
|
||||
os.makedirs(os.path.dirname(file_path))
|
||||
|
||||
@ -113,9 +111,9 @@ class GenerateService(CommandABC):
|
||||
Console.error(f'{String.first_to_upper(schematic)} already exists!')
|
||||
exit()
|
||||
|
||||
message = f'Creating {self._runtime.working_directory}/{template.path}/{template.name}'
|
||||
message = f'Creating {self._env.working_directory}/{template.path}/{template.name}'
|
||||
if template.path == '':
|
||||
message = f'Creating {self._runtime.working_directory}/{template.name}'
|
||||
message = f'Creating {self._env.working_directory}/{template.name}'
|
||||
|
||||
Console.spinner(
|
||||
message,
|
||||
|
Loading…
Reference in New Issue
Block a user