Improved version command
This commit is contained in:
parent
f8ebb4f1d7
commit
a8011267d9
@ -45,9 +45,14 @@ class VersionService(CommandABC):
|
|||||||
Console.write_line(f'OS: {platform.system()} {platform.processor()}')
|
Console.write_line(f'OS: {platform.system()} {platform.processor()}')
|
||||||
|
|
||||||
Console.write_line('\nCPL packages:')
|
Console.write_line('\nCPL packages:')
|
||||||
|
cpl_packages = [
|
||||||
|
'cpl_core',
|
||||||
|
'cpl_cli',
|
||||||
|
'cpl_query'
|
||||||
|
]
|
||||||
packages = []
|
packages = []
|
||||||
for importer, modname, is_pkg in pkgutil.iter_modules(cpl_core.__path__):
|
for modname in cpl_packages:
|
||||||
module = importer.find_module(modname).load_module(modname)
|
module = pkgutil.find_loader(modname).load_module(modname)
|
||||||
if '__version__' in dir(module):
|
if '__version__' in dir(module):
|
||||||
packages.append([f'{modname}', module.__version__])
|
packages.append([f'{modname}', module.__version__])
|
||||||
|
|
||||||
|
@ -25,30 +25,25 @@ 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
|
||||||
from cpl_cli.publish.publisher_abc import PublisherABC
|
from cpl_cli.publish.publisher_abc import PublisherABC
|
||||||
|
from cpl_core.environment import ApplicationEnvironment
|
||||||
|
|
||||||
|
|
||||||
class Startup(StartupABC):
|
class Startup(StartupABC):
|
||||||
|
|
||||||
def __init__(self, config: ConfigurationABC, services: ServiceCollectionABC):
|
def __init__(self):
|
||||||
StartupABC.__init__(self)
|
StartupABC.__init__(self)
|
||||||
|
|
||||||
self._configuration = config
|
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||||
self._env = self._configuration.environment
|
environment.set_runtime_directory(os.path.dirname(__file__))
|
||||||
self._services = services
|
configuration.argument_error_function = Error.error
|
||||||
|
|
||||||
self._env.set_runtime_directory(os.path.dirname(__file__))
|
configuration.add_environment_variables('PYTHON_')
|
||||||
|
configuration.add_environment_variables('CPL_')
|
||||||
|
configuration.add_json_file('appsettings.json', path=environment.runtime_directory, optional=False, output=False)
|
||||||
|
|
||||||
def configure_configuration(self) -> ConfigurationABC:
|
configuration.add_console_argument(ConsoleArgument('', 'add', ['a', 'a'], ' '))
|
||||||
self._configuration.argument_error_function = Error.error
|
configuration.add_console_argument(ConsoleArgument('', 'build', ['b', 'B'], ''))
|
||||||
|
configuration.add_console_argument(ConsoleArgument('', 'generate', ['g', 'G'], '', console_arguments=[
|
||||||
self._configuration.add_environment_variables('PYTHON_')
|
|
||||||
self._configuration.add_environment_variables('CPL_')
|
|
||||||
self._configuration.add_json_file('appsettings.json', path=self._env.runtime_directory,
|
|
||||||
optional=False, output=False)
|
|
||||||
|
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', 'add', ['a', 'a'], ' '))
|
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', 'build', ['b', 'B'], ''))
|
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', 'generate', ['g', 'G'], '', console_arguments=[
|
|
||||||
ConsoleArgument('', 'abc', ['a', 'A'], ' '),
|
ConsoleArgument('', 'abc', ['a', 'A'], ' '),
|
||||||
ConsoleArgument('', 'class', ['c', 'C'], ' '),
|
ConsoleArgument('', 'class', ['c', 'C'], ' '),
|
||||||
ConsoleArgument('', 'enum', ['e', 'E'], ' '),
|
ConsoleArgument('', 'enum', ['e', 'E'], ' '),
|
||||||
@ -56,54 +51,54 @@ class Startup(StartupABC):
|
|||||||
ConsoleArgument('', 'settings', ['st', 'ST'], ' '),
|
ConsoleArgument('', 'settings', ['st', 'ST'], ' '),
|
||||||
ConsoleArgument('', 'thread', ['t', 't'], ' ')
|
ConsoleArgument('', 'thread', ['t', 't'], ' ')
|
||||||
]))
|
]))
|
||||||
self._configuration.add_console_argument(
|
configuration.add_console_argument(
|
||||||
ConsoleArgument('', 'help', ['h', 'H'], ' ', is_value_token_optional=True)
|
ConsoleArgument('', 'help', ['h', 'H'], ' ', is_value_token_optional=True)
|
||||||
)
|
)
|
||||||
self._configuration.add_console_argument(
|
configuration.add_console_argument(
|
||||||
ConsoleArgument('', 'install', ['i', 'I'], ' ', is_value_token_optional=True)
|
ConsoleArgument('', 'install', ['i', 'I'], ' ', is_value_token_optional=True)
|
||||||
)
|
)
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', 'new', ['n', 'N'], '', console_arguments=[
|
configuration.add_console_argument(ConsoleArgument('', 'new', ['n', 'N'], '', console_arguments=[
|
||||||
ConsoleArgument('', 'console', ['c', 'C'], ' '),
|
ConsoleArgument('', 'console', ['c', 'C'], ' '),
|
||||||
ConsoleArgument('', 'library', ['l', 'L'], ' ')
|
ConsoleArgument('', 'library', ['l', 'L'], ' ')
|
||||||
]))
|
]))
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', 'publish', ['p', 'P'], ''))
|
configuration.add_console_argument(ConsoleArgument('', 'publish', ['p', 'P'], ''))
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', 'remove', ['r', 'R'], ' '))
|
configuration.add_console_argument(ConsoleArgument('', 'remove', ['r', 'R'], ' '))
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', 'start', ['s', 'S'], ''))
|
configuration.add_console_argument(ConsoleArgument('', 'start', ['s', 'S'], ''))
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', 'uninstall', ['ui', 'UI'], ' '))
|
configuration.add_console_argument(ConsoleArgument('', 'uninstall', ['ui', 'UI'], ' '))
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', 'update', ['u', 'U'], ''))
|
configuration.add_console_argument(ConsoleArgument('', 'update', ['u', 'U'], ''))
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', 'version', ['v', 'V'], ''))
|
configuration.add_console_argument(ConsoleArgument('', 'version', ['v', 'V'], ''))
|
||||||
|
|
||||||
self._configuration.add_console_argument(ConsoleArgument('', '--help', ['-h', '-H'], ''))
|
configuration.add_console_argument(ConsoleArgument('', '--help', ['-h', '-H'], ''))
|
||||||
|
|
||||||
if os.path.isfile(os.path.join(self._env.working_directory, 'cpl-workspace.json')):
|
if os.path.isfile(os.path.join(environment.working_directory, 'cpl-workspace.json')):
|
||||||
self._configuration.add_json_file('cpl-workspace.json', optional=True, output=False)
|
configuration.add_json_file('cpl-workspace.json', optional=True, output=False)
|
||||||
workspace: Optional[WorkspaceSettings] = self._configuration.get_configuration(WorkspaceSettings)
|
workspace: Optional[WorkspaceSettings] = configuration.get_configuration(WorkspaceSettings)
|
||||||
for script in workspace.scripts:
|
for script in workspace.scripts:
|
||||||
self._configuration.add_console_argument(
|
configuration.add_console_argument(
|
||||||
ConsoleArgument('', script, [], ' ', is_value_token_optional=True))
|
ConsoleArgument('', script, [], ' ', is_value_token_optional=True))
|
||||||
|
|
||||||
self._configuration.add_console_arguments(error=False)
|
configuration.add_console_arguments(error=False)
|
||||||
|
|
||||||
return self._configuration
|
return configuration
|
||||||
|
|
||||||
def configure_services(self) -> ServiceProviderABC:
|
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
||||||
self._services.add_singleton(CommandHandler)
|
services.add_singleton(CommandHandler)
|
||||||
|
|
||||||
self._services.add_transient(PublisherABC, PublisherService)
|
services.add_transient(PublisherABC, PublisherService)
|
||||||
self._services.add_transient(LiveServerService)
|
services.add_transient(LiveServerService)
|
||||||
|
|
||||||
self._services.add_transient(AddService)
|
services.add_transient(AddService)
|
||||||
self._services.add_transient(BuildService)
|
services.add_transient(BuildService)
|
||||||
self._services.add_transient(CustomScriptService)
|
services.add_transient(CustomScriptService)
|
||||||
self._services.add_transient(GenerateService)
|
services.add_transient(GenerateService)
|
||||||
self._services.add_transient(HelpService)
|
services.add_transient(HelpService)
|
||||||
self._services.add_transient(InstallService)
|
services.add_transient(InstallService)
|
||||||
self._services.add_transient(NewService)
|
services.add_transient(NewService)
|
||||||
self._services.add_transient(PublishService)
|
services.add_transient(PublishService)
|
||||||
self._services.add_transient(RemoveService)
|
services.add_transient(RemoveService)
|
||||||
self._services.add_transient(StartService)
|
services.add_transient(StartService)
|
||||||
self._services.add_transient(UninstallService)
|
services.add_transient(UninstallService)
|
||||||
self._services.add_transient(UpdateService)
|
services.add_transient(UpdateService)
|
||||||
self._services.add_transient(VersionService)
|
services.add_transient(VersionService)
|
||||||
|
|
||||||
return self._services.build_service_provider()
|
return services.build_service_provider()
|
||||||
|
Loading…
Reference in New Issue
Block a user