Merge pull request '2021.10.2' (#33) from 2021.10.2 into 2021.10

Reviewed-on: #33
This commit is contained in:
Sven Heidemann 2021-07-25 12:05:12 +02:00
commit d02548e1a8
29 changed files with 137 additions and 42 deletions

View File

@ -4,6 +4,8 @@
"Projects": { "Projects": {
"cpl": "src/cpl/cpl.json", "cpl": "src/cpl/cpl.json",
"cpl_cli": "src/cpl_cli/cpl_cli.json" "cpl_cli": "src/cpl_cli/cpl_cli.json"
},
"Scripts": {
} }
} }
} }

1
scripts/hello_world.py Normal file
View File

@ -0,0 +1 @@
print('Hello World')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
@ -29,4 +29,4 @@ from .main import main
from .startup import Startup from .startup import Startup
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.build'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.generate'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console.source'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console.source.name'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console.source.tests'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library.source'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library.source.name'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library.source.tests'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.publish'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -1,11 +1,14 @@
import os
from typing import Optional from typing import Optional
from cpl.application.application_abc import ApplicationABC from cpl.application.application_abc import ApplicationABC
from cpl.configuration.console_argument import ConsoleArgument
from cpl.configuration.configuration_abc import ConfigurationABC from cpl.configuration.configuration_abc import ConfigurationABC
from cpl.console.console import Console from cpl.console.console import Console
from cpl.dependency_injection import ServiceProviderABC from cpl.dependency_injection import ServiceProviderABC
from cpl_cli.command.add_service import AddService from cpl_cli.command.add_service import AddService
from cpl_cli.command.build_service import BuildService from cpl_cli.command.build_service import BuildService
from cpl_cli.command.custom_script_service import CustomScriptService
from cpl_cli.command.generate_service import GenerateService from cpl_cli.command.generate_service import GenerateService
from cpl_cli.command.install_service import InstallService from cpl_cli.command.install_service import InstallService
from cpl_cli.command.new_service import NewService from cpl_cli.command.new_service import NewService
@ -16,6 +19,7 @@ from cpl_cli.command.uninstall_service import UninstallService
from cpl_cli.command.update_service import UpdateService from cpl_cli.command.update_service import UpdateService
from cpl_cli.command_handler_service import CommandHandler from cpl_cli.command_handler_service import CommandHandler
from cpl_cli.command_model import CommandModel from cpl_cli.command_model import CommandModel
from cpl_cli.configuration.workspace_settings import WorkspaceSettings
from cpl_cli.error import Error from cpl_cli.error import Error
from cpl_cli.command.help_service import HelpService from cpl_cli.command.help_service import HelpService
from cpl_cli.command.version_service import VersionService from cpl_cli.command.version_service import VersionService
@ -48,6 +52,11 @@ class CLI(ApplicationABC):
self._command_handler.add_command(CommandModel('update', ['u', 'U'], UpdateService, False, True, True)) self._command_handler.add_command(CommandModel('update', ['u', 'U'], UpdateService, False, True, True))
self._command_handler.add_command(CommandModel('version', ['v', 'V'], VersionService, False, False, False)) self._command_handler.add_command(CommandModel('version', ['v', 'V'], VersionService, False, False, False))
if os.path.isfile(os.path.join(self._environment.working_directory, 'cpl-workspace.json')):
workspace: Optional[WorkspaceSettings] = self._configuration.get_configuration(WorkspaceSettings)
for script in workspace.scripts:
self._command_handler.add_command(CommandModel(script, [], CustomScriptService, True, True, False))
self._command_handler.add_command(CommandModel('--help', ['-h', '-H'], HelpService, False, False, False)) self._command_handler.add_command(CommandModel('--help', ['-h', '-H'], HelpService, False, False, False))
self._options.append('--help') self._options.append('--help')
@ -100,6 +109,10 @@ class CLI(ApplicationABC):
for arg in result_args: for arg in result_args:
args.append(arg) args.append(arg)
else:
Error.error(f'Unexpected command')
return
if command is None: if command is None:
Error.error(f'Expected command') Error.error(f'Expected command')
return return

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli.command'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
@ -28,4 +28,4 @@ from .publish_service import PublishService
from .version_service import VersionService from .version_service import VersionService
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -0,0 +1,39 @@
import os
import subprocess
import sys
from cpl.configuration.configuration_abc import ConfigurationABC
from cpl.console.console import Console
from cpl_cli.command_abc import CommandABC
from cpl_cli.configuration.workspace_settings import WorkspaceSettings
class CustomScriptService(CommandABC):
def __init__(self, config: ConfigurationABC, ws: WorkspaceSettings):
"""
Service for CLI scripts
"""
CommandABC.__init__(self)
self._config = config
self._workspace = ws
@property
def help_message(self) -> str:
return ''
def run(self, args: list[str]):
cmd = args[0] if len(args) > 0 else self._config.additional_arguments[0]
for script in self._workspace.scripts:
if script == cmd:
command = self._workspace.scripts[script]
try:
run_command = []
for word in command.split(' '):
run_command.append(word)
subprocess.run(run_command)
except Exception as e:
Console.error(str(e))

View File

@ -6,6 +6,7 @@ from cpl.configuration.configuration_abc import ConfigurationABC
from cpl.console.console import Console from cpl.console.console import Console
from cpl.dependency_injection.service_provider_abc import ServiceProviderABC from cpl.dependency_injection.service_provider_abc import ServiceProviderABC
from cpl.utils.string import String from cpl.utils.string import String
from cpl_cli.command.custom_script_service import CustomScriptService
from cpl_cli.configuration.workspace_settings import WorkspaceSettings from cpl_cli.configuration.workspace_settings import WorkspaceSettings
from cpl_cli.error import Error from cpl_cli.error import Error
from cpl_cli.command_model import CommandModel from cpl_cli.command_model import CommandModel
@ -57,7 +58,6 @@ class CommandHandler(ABC):
workspace: Optional[WorkspaceSettings] = None workspace: Optional[WorkspaceSettings] = None
if os.path.isfile(os.path.join(self._env.working_directory, 'cpl-workspace.json')): if os.path.isfile(os.path.join(self._env.working_directory, 'cpl-workspace.json')):
self._config.add_json_file('cpl-workspace.json', optional=True, output=False)
workspace = self._config.get_configuration(WorkspaceSettings) workspace = self._config.get_configuration(WorkspaceSettings)
if command.is_project_needed: if command.is_project_needed:
@ -111,5 +111,27 @@ class CommandHandler(ABC):
self._config.add_json_file(project_json, optional=True, output=False) self._config.add_json_file(project_json, optional=True, output=False)
self._services.get_service(command.command).run(args) # pre scripts
Console.write('\n') Console.write('\n')
self._handle_pre_or_post_scripts(True, workspace, command)
self._services.get_service(command.command).run(args)
# post scripts
Console.write('\n\n')
self._handle_pre_or_post_scripts(False, workspace, command)
Console.write('\n')
def _handle_pre_or_post_scripts(self, pre: bool, workspace: WorkspaceSettings, command: CommandModel):
script_type = 'pre-' if pre else 'post-'
if workspace is not None and len(workspace.scripts) > 0:
for script in workspace.scripts:
if script_type in script and script.split(script_type)[1] == command.name:
script_name = script
script_cmd = workspace.scripts[script]
if script_cmd in workspace.scripts:
script_name = workspace.scripts[script]
css: CustomScriptService = self._services.get_service(CustomScriptService)
if css is None:
continue
css.run([script_name])

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli.configuration'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
@ -30,4 +30,4 @@ from .workspace_settings import WorkspaceSettings
from .workspace_settings_name_enum import WorkspaceSettingsNameEnum from .workspace_settings_name_enum import WorkspaceSettingsNameEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -13,6 +13,7 @@ class WorkspaceSettings(ConfigurationModelABC):
self._default_project: Optional[str] = None self._default_project: Optional[str] = None
self._projects: dict[str, str] = {} self._projects: dict[str, str] = {}
self._scripts: dict[str, str] = {}
@property @property
def default_project(self) -> str: def default_project(self) -> str:
@ -22,10 +23,15 @@ class WorkspaceSettings(ConfigurationModelABC):
def projects(self) -> dict[str, str]: def projects(self) -> dict[str, str]:
return self._projects return self._projects
@property
def scripts(self):
return self._scripts
def from_dict(self, settings: dict): def from_dict(self, settings: dict):
try: try:
self._default_project = settings[WorkspaceSettingsNameEnum.default_project.value] self._default_project = settings[WorkspaceSettingsNameEnum.default_project.value]
self._projects = settings[WorkspaceSettingsNameEnum.projects.value] self._projects = settings[WorkspaceSettingsNameEnum.projects.value]
self._scripts = settings[WorkspaceSettingsNameEnum.scripts.value]
except Exception as e: except Exception as e:
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings') Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}') Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')

View File

@ -5,3 +5,4 @@ class WorkspaceSettingsNameEnum(Enum):
default_project = 'DefaultProject' default_project = 'DefaultProject'
projects = 'Projects' projects = 'Projects'
scripts = 'Scripts'

View File

@ -3,8 +3,8 @@
"Name": "sh_cpl-cli", "Name": "sh_cpl-cli",
"Version": { "Version": {
"Major": "2021", "Major": "2021",
"Minor": "4", "Minor": "10",
"Micro": "0.post3" "Micro": "2"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.live_server'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli.publish'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
@ -24,4 +24,4 @@ from .publisher_abc import PublisherABC
from .publisher_service import PublisherService from .publisher_service import PublisherService
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.source_creator'
__author__ = 'Sven Heidemann' __author__ = 'Sven Heidemann'
__license__ = 'MIT' __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de' __copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0.post3' __version__ = '2021.10.2'
from collections import namedtuple from collections import namedtuple
# imports: # imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro') VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='4', micro='0.post3') version_info = VersionInfo(major='2021', minor='10', micro='2')

View File

@ -1,4 +1,5 @@
import os import os
from typing import Optional
from cpl.application.startup_abc import StartupABC from cpl.application.startup_abc import StartupABC
from cpl.configuration.console_argument import ConsoleArgument from cpl.configuration.console_argument import ConsoleArgument
@ -7,6 +8,7 @@ from cpl.dependency_injection.service_collection_abc import ServiceCollectionABC
from cpl.dependency_injection.service_provider_abc import ServiceProviderABC from cpl.dependency_injection.service_provider_abc import ServiceProviderABC
from cpl_cli.command.add_service import AddService from cpl_cli.command.add_service import AddService
from cpl_cli.command.build_service import BuildService from cpl_cli.command.build_service import BuildService
from cpl_cli.command.custom_script_service import CustomScriptService
from cpl_cli.command.generate_service import GenerateService from cpl_cli.command.generate_service import GenerateService
from cpl_cli.command.install_service import InstallService from cpl_cli.command.install_service import InstallService
from cpl_cli.command.new_service import NewService from cpl_cli.command.new_service import NewService
@ -18,6 +20,7 @@ from cpl_cli.command.update_service import UpdateService
from cpl_cli.command_handler_service import CommandHandler from cpl_cli.command_handler_service import CommandHandler
from cpl_cli.command.help_service import HelpService from cpl_cli.command.help_service import HelpService
from cpl_cli.command.version_service import VersionService from cpl_cli.command.version_service import VersionService
from cpl_cli.configuration.workspace_settings import WorkspaceSettings
from cpl_cli.error import Error from cpl_cli.error import Error
from cpl_cli.live_server.live_server_service import LiveServerService from cpl_cli.live_server.live_server_service import LiveServerService
from cpl_cli.publish.publisher_service import PublisherService from cpl_cli.publish.publisher_service import PublisherService
@ -72,6 +75,13 @@ class Startup(StartupABC):
self._configuration.add_console_argument(ConsoleArgument('', '--help', ['-h', '-H'], '')) self._configuration.add_console_argument(ConsoleArgument('', '--help', ['-h', '-H'], ''))
if os.path.isfile(os.path.join(self._env.working_directory, 'cpl-workspace.json')):
self._configuration.add_json_file('cpl-workspace.json', optional=True, output=False)
workspace: Optional[WorkspaceSettings] = self._configuration.get_configuration(WorkspaceSettings)
for script in workspace.scripts:
self._configuration.add_console_argument(
ConsoleArgument('', script, [], ' ', is_value_token_optional=True))
self._configuration.add_console_arguments(error=False) self._configuration.add_console_arguments(error=False)
return self._configuration return self._configuration
@ -84,6 +94,7 @@ class Startup(StartupABC):
self._services.add_transient(AddService) self._services.add_transient(AddService)
self._services.add_transient(BuildService) self._services.add_transient(BuildService)
self._services.add_transient(CustomScriptService)
self._services.add_transient(GenerateService) self._services.add_transient(GenerateService)
self._services.add_transient(HelpService) self._services.add_transient(HelpService)
self._services.add_transient(InstallService) self._services.add_transient(InstallService)