From 260fe06be8b1680f355294af53b7c6734c4674b4 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 30 Mar 2021 09:54:04 +0200 Subject: [PATCH] Improved new command --- src/cpl_cli/command/new_service.py | 19 +++++---- .../templates/new/console/appsettings_json.py | 41 +++++++++++++++++++ 2 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 src/cpl_cli/templates/new/console/appsettings_json.py diff --git a/src/cpl_cli/command/new_service.py b/src/cpl_cli/command/new_service.py index 34e4fc83..0926b4c9 100644 --- a/src/cpl_cli/command/new_service.py +++ b/src/cpl_cli/command/new_service.py @@ -16,6 +16,7 @@ from cpl_cli.configuration.build_settings_name_enum import BuildSettingsNameEnum from cpl_cli.configuration.project_settings import ProjectSettings from cpl_cli.configuration.project_settings_name_enum import ProjectSettingsNameEnum from cpl_cli.configuration.version_settings_name_enum import VersionSettingsNameEnum +from cpl_cli.templates.new.console.appsettings_json import AppsettingsTemplate from cpl_cli.templates.new.console.license import LicenseTemplate from cpl_cli.templates.new.console.readme_py import ReadmeTemplate from cpl_cli.templates.new.console.src.application import ApplicationTemplate @@ -142,14 +143,13 @@ class NewService(CommandABC): if result.lower() == 'y': self._use_application_api = True - result = Console.read('Do you want to use service providing? (y/n) ') - if result.lower() == 'y': - self._use_service_providing = True - - if self._use_application_api: - result = Console.read('Do you want to use startup? (y/n) ') - if result.lower() == 'y': - self._use_startup = True + result = Console.read('Do you want to use startup? (y/n) ') + if result.lower() == 'y': + self._use_startup = True + else: + result = Console.read('Do you want to use service providing? (y/n) ') + if result.lower() == 'y': + self._use_service_providing = True Console.set_foreground_color(ForegroundColorEnum.default) @@ -169,7 +169,8 @@ class NewService(CommandABC): templates: list[TemplateFileABC] = [ LicenseTemplate(), ReadmeTemplate(), - TestsInitTemplate() + TestsInitTemplate(), + AppsettingsTemplate() ] if self._use_application_api: diff --git a/src/cpl_cli/templates/new/console/appsettings_json.py b/src/cpl_cli/templates/new/console/appsettings_json.py new file mode 100644 index 00000000..04c1a239 --- /dev/null +++ b/src/cpl_cli/templates/new/console/appsettings_json.py @@ -0,0 +1,41 @@ +import textwrap + +from cpl_cli.templates.template_file_abc import TemplateFileABC + + +class AppsettingsTemplate(TemplateFileABC): + + def __init__(self): + TemplateFileABC.__init__(self) + + self._name = 'appsettings.json' + self._path = '' + self._value = textwrap.dedent("""\ + { + "TimeFormatSettings": { + "DateFormat": "%Y-%m-%d", + "TimeFormat": "%H:%M:%S", + "DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f", + "DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S" + }, + + "LoggingSettings": { + "Path": "logs/", + "Filename": "log_$start_time.log", + "ConsoleLogLevel": "ERROR", + "FileLogLevel": "WARN" + } + } + """) + + @property + def name(self) -> str: + return self._name + + @property + def path(self) -> str: + return self._path + + @property + def value(self) -> str: + return self._value