Added functions to define console arguments
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
from cpl_core.configuration.runnable_argument_abc import RunnableArgumentABC
|
||||
from cpl_core.console import Console
|
||||
|
||||
|
||||
class GenerateArgument(RunnableArgumentABC):
|
||||
|
||||
def __init__(self):
|
||||
RunnableArgumentABC.__init__(self)
|
||||
|
||||
def run(self, args: list[str]):
|
||||
Console.write_line('Generate:', args)
|
@@ -0,0 +1,11 @@
|
||||
from cpl_core.configuration.runnable_argument_abc import RunnableArgumentABC
|
||||
from cpl_core.console import Console
|
||||
|
||||
|
||||
class InstallArgument(RunnableArgumentABC):
|
||||
|
||||
def __init__(self):
|
||||
RunnableArgumentABC.__init__(self)
|
||||
|
||||
def run(self, args: list[str]):
|
||||
Console.write_line('Install:', args)
|
@@ -3,11 +3,13 @@ from cpl_core.application import ApplicationBuilder
|
||||
from test_extension import TestExtension
|
||||
from startup import Startup
|
||||
from test_startup_extension import TestStartupExtension
|
||||
from parameter_startup import ParameterStartup
|
||||
|
||||
|
||||
def main():
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.use_startup(Startup)
|
||||
app_builder.use_extension(ParameterStartup)
|
||||
app_builder.use_extension(TestStartupExtension)
|
||||
app_builder.use_extension(TestExtension)
|
||||
app_builder.build().run()
|
||||
|
31
src/tests/custom/general/src/general/parameter_startup.py
Normal file
31
src/tests/custom/general/src/general/parameter_startup.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from cpl_core.application import StartupExtensionABC
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_core.dependency_injection import ServiceCollectionABC
|
||||
from cpl_core.environment import ApplicationEnvironmentABC
|
||||
from arguments.generate_argument import GenerateArgument
|
||||
from arguments.install_argument import InstallArgument
|
||||
|
||||
|
||||
class ParameterStartup(StartupExtensionABC):
|
||||
|
||||
def __init__(self):
|
||||
StartupExtensionABC.__init__(self)
|
||||
|
||||
def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC):
|
||||
config.create_console_argument('', 'generate', ['g', 'G'], '', runnable=GenerateArgument) \
|
||||
.add_console_argument('', 'abc', ['a', 'A'], ' ') \
|
||||
.add_console_argument('', 'class', ['c', 'C'], ' ') \
|
||||
.add_console_argument('', 'enum', ['e', 'E'], ' ') \
|
||||
.add_console_argument('', 'service', ['s', 'S'], ' ') \
|
||||
.add_console_argument('', 'settings', ['st', 'ST'], ' ') \
|
||||
.add_console_argument('', 'thread', ['t', 'T'], ' ') \
|
||||
.add_console_argument('-', 'o', ['o', 'O'], '=')
|
||||
config.create_console_argument('', 'install', ['i', 'I'], ' ', is_value_token_optional=True,
|
||||
runnable=InstallArgument) \
|
||||
.add_console_argument('--', 'virtual', ['v', 'V'], '') \
|
||||
.add_console_argument('--', 'simulate', ['s', 'S'], '')
|
||||
|
||||
def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC):
|
||||
services \
|
||||
.add_singleton(GenerateArgument) \
|
||||
.add_singleton(InstallArgument)
|
Reference in New Issue
Block a user