2021.4.7 #29

Merged
edraft merged 9 commits from 2021.4.7 into 2021.4.post1 2021-04-13 15:47:25 +02:00
14 changed files with 105 additions and 3 deletions
Showing only changes of commit 93829027af - Show all commits

View File

@ -1,5 +1,6 @@
import json import json
import os.path import os
import textwrap
from typing import Optional from typing import Optional
from cpl.configuration.configuration_abc import ConfigurationABC from cpl.configuration.configuration_abc import ConfigurationABC
@ -24,6 +25,11 @@ class AddService(CommandABC):
self._workspace = workspace self._workspace = workspace
@property
def help_message(self) -> str:
return textwrap.dedent("""\
""")
@staticmethod @staticmethod
def _edit_project_file(source: str, project_settings: ProjectSettings, build_settings: BuildSettings): def _edit_project_file(source: str, project_settings: ProjectSettings, build_settings: BuildSettings):
with open(source, 'w') as file: with open(source, 'w') as file:

View File

@ -1,3 +1,5 @@
import textwrap
from cpl_cli.command_abc import CommandABC from cpl_cli.command_abc import CommandABC
from cpl_cli.publish.publisher_abc import PublisherABC from cpl_cli.publish.publisher_abc import PublisherABC
@ -13,6 +15,11 @@ class BuildService(CommandABC):
self._publisher = publisher self._publisher = publisher
@property
def help_message(self) -> str:
return textwrap.dedent("""\
""")
def run(self, args: list[str]): def run(self, args: list[str]):
""" """
Entry point of command Entry point of command

View File

@ -1,4 +1,5 @@
import os import os
import textwrap
from collections import Callable from collections import Callable
from cpl.configuration.configuration_abc import ConfigurationABC from cpl.configuration.configuration_abc import ConfigurationABC
@ -55,6 +56,11 @@ class GenerateService(CommandABC):
self._config = configuration self._config = configuration
self._env = self._config.environment self._env = self._config.environment
@property
def help_message(self) -> str:
return textwrap.dedent("""\
""")
@staticmethod @staticmethod
def _help(message: str): def _help(message: str):
""" """

View File

@ -1,22 +1,49 @@
import textwrap
from typing import Optional
from cpl.console.console import Console from cpl.console.console import Console
from cpl.console.foreground_color_enum import ForegroundColorEnum from cpl.console.foreground_color_enum import ForegroundColorEnum
from cpl.dependency_injection.service_provider_abc import ServiceProviderABC
from cpl_cli.command_handler_service import CommandHandler
from cpl_cli.command_abc import CommandABC from cpl_cli.command_abc import CommandABC
class HelpService(CommandABC): class HelpService(CommandABC):
def __init__(self): def __init__(self, services: ServiceProviderABC, cmd_handler: CommandHandler):
""" """
Service for CLI command help Service for CLI command help
""" """
CommandABC.__init__(self) CommandABC.__init__(self)
self._services = services
self._commands = cmd_handler.commands
@property
def help_message(self) -> str:
return textwrap.dedent("""\
""")
def run(self, args: list[str]): def run(self, args: list[str]):
""" """
Entry point of command Entry point of command
:param args: :param args:
:return: :return:
""" """
if len(args) > 0:
command_name = args[0]
command: Optional[CommandABC] = None
for cmd in self._commands:
if cmd.name == command_name:
command = self._services.get_service(cmd.command)
if command is None:
Console.error(f'Invalid argument: {command_name}')
Console.write_line(command.help_message)
return
Console.write_line('Available Commands:') Console.write_line('Available Commands:')
commands = [ commands = [
['add (a|a)', 'Adds a project reference to given project.'], ['add (a|a)', 'Adds a project reference to given project.'],

View File

@ -1,6 +1,7 @@
import json import json
import os import os
import subprocess import subprocess
import textwrap
from packaging import version from packaging import version
@ -39,6 +40,11 @@ class InstallService(CommandABC):
self._project_file = f'{self._config.get_configuration("ProjectName")}.json' self._project_file = f'{self._config.get_configuration("ProjectName")}.json'
@property
def help_message(self) -> str:
return textwrap.dedent("""\
""")
def _install_project(self): def _install_project(self):
""" """
Installs dependencies of CPl project Installs dependencies of CPl project

View File

@ -1,5 +1,6 @@
import os import os
import sys import sys
import textwrap
from typing import Optional from typing import Optional
from packaging import version from packaging import version
@ -46,6 +47,11 @@ class NewService(CommandABC):
self._use_startup: bool = False self._use_startup: bool = False
self._use_service_providing: bool = False self._use_service_providing: bool = False
@property
def help_message(self) -> str:
return textwrap.dedent("""\
""")
@staticmethod @staticmethod
def _help(message: str): def _help(message: str):
""" """

View File

@ -1,3 +1,5 @@
import textwrap
from cpl_cli.command_abc import CommandABC from cpl_cli.command_abc import CommandABC
from cpl_cli.publish.publisher_abc import PublisherABC from cpl_cli.publish.publisher_abc import PublisherABC
@ -13,6 +15,11 @@ class PublishService(CommandABC):
self._publisher = publisher self._publisher = publisher
@property
def help_message(self) -> str:
return textwrap.dedent("""\
""")
def run(self, args: list[str]): def run(self, args: list[str]):
""" """
Entry point of command Entry point of command

View File

@ -1,6 +1,7 @@
import os import os
import shutil import shutil
import json import json
import textwrap
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
@ -25,6 +26,11 @@ class RemoveService(CommandABC):
self._workspace: WorkspaceSettings = self._config.get_configuration(WorkspaceSettings) self._workspace: WorkspaceSettings = self._config.get_configuration(WorkspaceSettings)
@property
def help_message(self) -> str:
return textwrap.dedent("""\
""")
@staticmethod @staticmethod
def _create_file(file_name: str, content: dict): def _create_file(file_name: str, content: dict):
if not os.path.isabs(file_name): if not os.path.isabs(file_name):

View File

@ -1,3 +1,5 @@
import textwrap
from cpl_cli.command_abc import CommandABC from cpl_cli.command_abc import CommandABC
from cpl_cli.live_server.live_server_service import LiveServerService from cpl_cli.live_server.live_server_service import LiveServerService
@ -13,6 +15,11 @@ class StartService(CommandABC):
self._live_server = live_server self._live_server = live_server
@property
def help_message(self) -> str:
return textwrap.dedent("""\
""")
def run(self, args: list[str]): def run(self, args: list[str]):
""" """
Entry point of command Entry point of command

View File

@ -1,6 +1,7 @@
import json import json
import os import os
import subprocess import subprocess
import textwrap
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
@ -31,6 +32,11 @@ class UninstallService(CommandABC):
self._build_settings = build_settings self._build_settings = build_settings
self._project_settings = project_settings self._project_settings = project_settings
@property
def help_message(self) -> str:
return textwrap.dedent("""\
""")
def run(self, args: list[str]): def run(self, args: list[str]):
""" """
Entry point of command Entry point of command

View File

@ -1,6 +1,7 @@
import json import json
import os import os
import subprocess import subprocess
import textwrap
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
@ -38,6 +39,11 @@ class UpdateService(CommandABC):
self._project_settings = project_settings self._project_settings = project_settings
self._cli_settings = cli_settings self._cli_settings = cli_settings
@property
def help_message(self) -> str:
return textwrap.dedent("""\
""")
def _collect_project_dependencies(self) -> list[tuple]: def _collect_project_dependencies(self) -> list[tuple]:
""" """
Collects project dependencies Collects project dependencies

View File

@ -2,6 +2,7 @@ import pkgutil
import sys import sys
import platform import platform
import pkg_resources import pkg_resources
import textwrap
import cpl import cpl
import cpl_cli import cpl_cli
@ -18,6 +19,11 @@ class VersionService(CommandABC):
""" """
CommandABC.__init__(self) CommandABC.__init__(self)
@property
def help_message(self) -> str:
return textwrap.dedent("""\
""")
def run(self, args: list[str]): def run(self, args: list[str]):
""" """
Entry point of command Entry point of command

View File

@ -7,5 +7,9 @@ class CommandABC(ABC):
def __init__(self): def __init__(self):
ABC.__init__(self) ABC.__init__(self)
@property
@abstractmethod
def help_message(self) -> str: pass
@abstractmethod @abstractmethod
def run(self, args: list[str]): pass def run(self, args: list[str]): pass

View File

@ -53,7 +53,9 @@ class Startup(StartupABC):
ConsoleArgument('', 'settings', ['st', 'ST'], ' '), ConsoleArgument('', 'settings', ['st', 'ST'], ' '),
ConsoleArgument('', 'thread', ['t', 't'], ' ') ConsoleArgument('', 'thread', ['t', 't'], ' ')
])) ]))
self._configuration.add_console_argument(ConsoleArgument('', 'help', ['h', 'H'], '')) self._configuration.add_console_argument(
ConsoleArgument('', 'help', ['h', 'H'], ' ', is_value_token_optional=True)
)
self._configuration.add_console_argument( self._configuration.add_console_argument(
ConsoleArgument('', 'install', ['i', 'I'], ' ', is_value_token_optional=True) ConsoleArgument('', 'install', ['i', 'I'], ' ', is_value_token_optional=True)
) )