orionis 0.80.0__py3-none-any.whl → 0.84.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,13 +3,6 @@ from typing import Any, Callable
3
3
 
4
4
  class IContainer(ABC):
5
5
 
6
- @abstractmethod
7
- def _newRequest(self) -> None:
8
- """
9
- Reset scoped instances at the beginning of a new request.
10
- """
11
- pass
12
-
13
6
  @abstractmethod
14
7
  def _ensureNotMain(self, concrete: Callable[..., Any]) -> str:
15
8
  """
@@ -83,6 +76,13 @@ class IContainer(ABC):
83
76
  """
84
77
  pass
85
78
 
79
+ @abstractmethod
80
+ def forgetScopedInstances(self) -> None:
81
+ """
82
+ Reset scoped instances at the beginning of a new request.
83
+ """
84
+ self._scoped_instances = {}
85
+
86
86
  @abstractmethod
87
87
  def bind(self, concrete: Callable[..., Any]) -> str:
88
88
  """
@@ -0,0 +1,40 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any
3
+
4
+ class ICommand(ABC):
5
+ """
6
+ Interface for defining a CLI command.
7
+ Command class for managing and executing registered CLI commands.
8
+
9
+ This class provides a static method to invoke commands registered in the
10
+ `CacheCommands` singleton, passing the required signature and any additional
11
+ parameters.
12
+
13
+ Methods
14
+ -------
15
+ call(signature: str, vars: dict[str, Any] = {}, *args: Any, **kwargs: Any) -> Any
16
+ Executes the specified command with the provided arguments.
17
+ """
18
+
19
+ @abstractmethod
20
+ def call(signature: str, vars: dict[str, Any] = {}, *args: Any, **kwargs: Any) -> Any:
21
+ """
22
+ Calls a registered command using the `CLIRunner`.
23
+
24
+ Parameters
25
+ ----------
26
+ signature : str
27
+ The command signature (name) to execute.
28
+ vars : dict[str, Any], optional
29
+ A dictionary containing named arguments for the command (default is `{}`).
30
+ *args : Any
31
+ Additional positional arguments.
32
+ **kwargs : Any
33
+ Additional keyword arguments.
34
+
35
+ Returns
36
+ -------
37
+ Any
38
+ The output of the executed command.
39
+ """
40
+ pass
File without changes
@@ -0,0 +1,23 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Optional
3
+
4
+ class IReactorCommandsService(ABC):
5
+ """
6
+ Interface for the ReactorCommandsService class.
7
+ Service responsible for executing and managing CLI commands in Orionis.
8
+
9
+ This service handles:
10
+ - Parsing command arguments.
11
+ - Executing commands and logging their output.
12
+ - Managing execution timing and error handling.
13
+ """
14
+
15
+ @abstractmethod
16
+ def execute(self, signature: Optional[str] = None, vars: dict = {}, *args, **kwargs):
17
+ """
18
+ Processes and executes a CLI command.
19
+
20
+ Determines if the command originates from `sys.argv` or is explicitly called,
21
+ then executes the appropriate command pipeline, handling success and errors.
22
+ """
23
+ pass
orionis/framework.py CHANGED
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.80.0"
8
+ VERSION = "0.84.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
orionis/luminate/app.py CHANGED
@@ -1,79 +1,274 @@
1
+ from typing import Any, Callable
1
2
  from orionis.luminate.container.container import Container
2
3
  from orionis.luminate.bootstrap.config_bootstrapper import ConfigBootstrapper
3
4
  from orionis.luminate.bootstrap.command_bootstrapper import CommandsBootstrapper
4
5
  from orionis.luminate.bootstrap.environment_bootstrapper import EnvironmentBootstrapper
5
6
  from orionis.luminate.patterns.singleton import SingletonMeta
7
+ from orionis.luminate.providers.commands.reactor_commands_service_provider import ReactorCommandsServiceProvider
6
8
  from orionis.luminate.providers.environment.environment__service_provider import EnvironmentServiceProvider
7
9
  from orionis.luminate.providers.config.config_service_provider import ConfigServiceProvider
8
10
  from orionis.luminate.providers.log.log_service_provider import LogServiceProvider
9
- from orionis.luminate.facades.log.log_facade import Log
11
+ from orionis.luminate.facades.commands.commands_facade import Command
10
12
 
11
13
  class Application(metaclass=SingletonMeta):
14
+ """
15
+ The core Application class responsible for bootstrapping and managing the application lifecycle.
16
+
17
+ This class follows the Singleton pattern to ensure a single instance throughout the application.
18
+
19
+ Attributes
20
+ ----------
21
+ _config : dict
22
+ A dictionary to store application configuration.
23
+ _commands : dict
24
+ A dictionary to store application commands.
25
+ _environment_vars : dict
26
+ A dictionary to store environment variables.
27
+ container : Container
28
+ The dependency injection container for the application.
29
+
30
+ Methods
31
+ -------
32
+ boot()
33
+ Bootstraps the application by loading environment, configuration, and core providers.
34
+ _beforeBootstrapProviders()
35
+ Registers and boots essential providers required before bootstrapping.
36
+ _bootstraping()
37
+ Loads user-defined configuration, commands, and environment variables.
38
+ _afterBootstrapProviders()
39
+ Registers and boots additional providers after bootstrapping.
40
+ """
12
41
 
13
42
  def __init__(self, container: Container):
43
+ """
44
+ Initializes the Application instance.
14
45
 
15
- # Atributos de la clase
16
- self._config = {}
17
- self._commands = {}
18
- self._environment_vars = {}
46
+ Parameters
47
+ ----------
48
+ container : Container
49
+ The dependency injection container for the application.
50
+ """
51
+ # Class attributes
52
+ self._config: dict = {}
53
+ self._commands: dict = {}
54
+ self._environment_vars: dict = {}
55
+ self._booted: bool = False
19
56
 
20
- # Inicializar el contenedor de la aplicacion
57
+ # Initialize the application container
21
58
  self.container = container
22
59
  self.container.instance(container)
60
+ self.boot()
61
+
62
+ def isBooted(self) -> bool:
63
+ """
64
+ Check if the application has been booted.
65
+
66
+ Returns
67
+ -------
68
+ bool
69
+ True if the application has been booted, False otherwise.
70
+ """
71
+ return self._booted
72
+
73
+ def bind(self, concrete: Callable[..., Any]) -> str:
74
+ """
75
+ Bind a callable to the container.
76
+ This method ensures that the provided callable is not the main function,
77
+ is unique within the container, and is indeed callable. It then creates
78
+ a unique key for the callable based on its module and name, and stores
79
+ the callable in the container's bindings.
80
+ Args:
81
+ concrete (Callable[..., Any]): The callable to be bound to the container.
82
+ Returns:
83
+ str: The unique key generated for the callable.
84
+ """
85
+ return self.container.bind(concrete)
86
+
87
+ def transient(self, concrete: Callable[..., Any]) -> str:
88
+ """
89
+ Registers a transient service in the container.
90
+ A transient service is created each time it is requested.
91
+ Args:
92
+ concrete (Callable[..., Any]): The callable that defines the service.
93
+ Returns:
94
+ str: The unique key generated for the callable.
95
+ """
96
+ return self.container.transient(concrete)
97
+
98
+ def singleton(self, concrete: Callable[..., Any]) -> str:
99
+ """
100
+ Registers a callable as a singleton in the container.
101
+ This method ensures that the provided callable is not the main module,
102
+ is unique within the container, and is indeed callable. It then registers
103
+ the callable as a singleton, storing it in the container's singleton registry.
104
+ Args:
105
+ concrete (Callable[..., Any]): The callable to be registered as a singleton.
106
+ Returns:
107
+ str: The key under which the singleton is registered in the container.
108
+ """
109
+ return self.container.singleton(concrete)
110
+
111
+ def scoped(self, concrete: Callable[..., Any]) -> str:
112
+ """
113
+ Registers a callable as a scoped service.
114
+ This method ensures that the provided callable is not the main service,
115
+ is unique, and is indeed callable. It then registers the callable in the
116
+ scoped services dictionary with relevant metadata.
117
+ Args:
118
+ concrete (Callable[..., Any]): The callable to be registered as a scoped service.
119
+ Returns:
120
+ str: The key under which the callable is registered in the scoped services dictionary.
121
+ """
122
+ return self.container.scoped(concrete)
123
+
124
+ def instance(self, instance: Any) -> str:
125
+ """
126
+ Registers an instance as a singleton in the container.
127
+ Args:
128
+ instance (Any): The instance to be registered as a singleton.
129
+ Returns:
130
+ str: The key under which the instance is registered in the container.
131
+ """
132
+ return self.container.instance(instance)
133
+
134
+ def alias(self, alias: str, concrete: Any) -> None:
135
+ """
136
+ Creates an alias for a registered service.
137
+ Args:
138
+ alias (str): The alias name to be used for the service.
139
+ concrete (Any): The actual service instance or callable to be aliased.
140
+ Raises:
141
+ OrionisContainerException: If the concrete instance is not a valid object or if the alias is a primitive type.
142
+ """
143
+ return self.container.alias(alias, concrete)
144
+
145
+ def has(self, obj: Any) -> bool:
146
+ """
147
+ Checks if a service is registered in the container.
23
148
 
24
- # Cargar el servidor de entorno
25
- self._loadServiceProviderEnvironment()
149
+ Parameters
150
+ ----------
151
+ obj : Any
152
+ The service class, instance, or alias to check.
26
153
 
27
- # Cargar dinamicamente la configurcion de la aplicacion.
154
+ Returns
155
+ -------
156
+ bool
157
+ True if the service is registered, False otherwise.
158
+ """
159
+ return self.container.has(obj)
160
+
161
+ def make(self, abstract: Any) -> Any:
162
+ """
163
+ Create and return an instance of a registered service.
164
+
165
+ Parameters
166
+ ----------
167
+ abstract : Any
168
+ The service class or alias to instantiate.
169
+
170
+ Returns
171
+ -------
172
+ Any
173
+ An instance of the requested service.
174
+
175
+ Raises
176
+ ------
177
+ OrionisContainerException
178
+ If the service is not found in the container.
179
+ """
180
+ return self.container.make(abstract)
181
+
182
+ def forgetScopedInstances(self) -> None:
183
+ """
184
+ Reset scoped instances at the beginning of a new request.
185
+ """
186
+ return self.container.forgetScopedInstances()
187
+
188
+ def boot(self):
189
+ """
190
+ Bootstraps the application.
191
+
192
+ This method is responsible for loading the environment, configuration, and core providers.
193
+ It ensures the application is ready to handle requests or commands.
194
+ """
195
+ # Load environment server
196
+ self._beforeBootstrapProviders()
197
+
198
+ # Dynamically load application configuration
28
199
  self._bootstraping()
29
200
 
30
- # Registrrar los comandos en el contenedor
31
- self._registerCommands()
201
+ # Load core providers
202
+ self._afterBootstrapProviders()
32
203
 
33
- # Cargar de provedores core
34
- self._loadServiceProviderCore()
204
+ # Set the booted flag to True
205
+ self._booted = True
35
206
 
36
- def _loadServiceProviderEnvironment(self):
207
+ def _beforeBootstrapProviders(self):
208
+ """
209
+ Registers and boots essential providers required before bootstrapping.
37
210
 
38
- # Cargar el proveedor de entorno
211
+ This method ensures that environment variables are loaded and available
212
+ for use during the bootstrapping process.
213
+ """
214
+ # Load the environment provider, which is responsible for returning values from the .env file.
215
+ # This provider is essential as it must be loaded first to resolve environment variables.
216
+ # Developers can interact with it through the facade "orionis.luminate.facades.environment.environment_facade.Env".
39
217
  _environment_provider = EnvironmentServiceProvider(app=self.container)
40
218
  _environment_provider.register()
41
219
  _environment_provider.boot()
42
220
 
43
221
  def _bootstraping(self):
222
+ """
223
+ Loads user-defined configuration, commands, and environment variables.
44
224
 
45
- # Cargar la configuracion de la aplicacion
46
- config_bootstrapper_key = self.container.singleton(ConfigBootstrapper)
47
- config_bootstrapper: ConfigBootstrapper = self.container.make(config_bootstrapper_key)
225
+ This method initializes the configuration, commands, and environment variables
226
+ required for the application to function.
227
+ """
228
+ # This initializer loads the user-defined configuration from the "config" folder.
229
+ # It extracts configuration values and stores them as class properties for future use.
230
+ config_bootstrapper_key = self.singleton(ConfigBootstrapper)
231
+ config_bootstrapper: ConfigBootstrapper = self.make(config_bootstrapper_key)
48
232
  self._config = config_bootstrapper.get()
49
233
 
50
- # Cargar los comandos propios y definidos por el desarrollador
51
- commands_bootstrapper_key = self.container.singleton(CommandsBootstrapper)
52
- commands_bootstrapper: CommandsBootstrapper = self.container.make(commands_bootstrapper_key)
234
+ # This initializer dynamically searches for all user-defined commands in the "commands" folder,
235
+ # both from the framework core and developer-defined commands.
236
+ # It stores them in a dictionary and registers them in the container.
237
+ commands_bootstrapper_key = self.singleton(CommandsBootstrapper)
238
+ commands_bootstrapper: CommandsBootstrapper = self.make(commands_bootstrapper_key)
53
239
  self._commands = commands_bootstrapper.get()
240
+ for command in self._commands.keys():
241
+ _key_instance_container = self.bind(self._commands[command].get('concrete'))
242
+ self.alias(alias=command, concrete=_key_instance_container)
54
243
 
55
- # Cargar las variables de entorno solo desde el archivo .env (No se carga desde el sistema operativo, por seguridad)
56
- environment_bootstrapper_key = self.container.singleton(EnvironmentBootstrapper)
57
- environment_bootstrapper: EnvironmentBootstrapper = self.container.make(environment_bootstrapper_key)
244
+ # Load environment variables and store them as class properties.
245
+ # This is useful for executing future tasks conditioned on environment values.
246
+ environment_bootstrapper_key = self.singleton(EnvironmentBootstrapper)
247
+ environment_bootstrapper: EnvironmentBootstrapper = self.make(environment_bootstrapper_key)
58
248
  self._environment_vars = environment_bootstrapper.get()
59
249
 
60
- def _registerCommands(self):
61
-
62
- # Registrar los comandos en el contenedor
63
- for command in self._commands:
64
- _key_instance_container = self.container.bind(self._commands[command].get('concrete'))
65
- self.container.alias(alias=command, concrete=_key_instance_container)
250
+ def _afterBootstrapProviders(self):
251
+ """
252
+ Registers and boots additional providers after bootstrapping.
66
253
 
67
- def _loadServiceProviderCore(self):
68
-
69
- # Cargar el proveedor de configuracion
254
+ This method ensures that configuration and logging providers are loaded
255
+ and available for use in the application.
256
+ """
257
+ # Load the configuration provider, which is responsible for returning configuration values.
258
+ # Developers can interact with it through the facade "orionis.luminate.facades.config.config_facade.Config".
70
259
  _environment_provider = ConfigServiceProvider(app=self.container)
71
260
  _environment_provider.register()
72
261
  _environment_provider.boot()
73
262
 
74
- # Cargar el proveedor de log
263
+
264
+ # Load the log provider based on the application configuration defined by the developer.
265
+ # Developers can interact with it through the facade "orionis.luminate.facades.log.log_facade.Log".
75
266
  _log_provider = LogServiceProvider(app=self.container)
76
267
  _log_provider.register()
77
268
  _log_provider.boot()
78
269
 
79
- Log.info('Application is ready to run')
270
+ # Load the commands provider, which is responsible for executing and managing CLI commands.
271
+ # Developers can interact with it through the facade "orionis.luminate.facades.commands.commands_facade.Commands".
272
+ _commands_provider = ReactorCommandsServiceProvider(app=self.container)
273
+ _commands_provider.register()
274
+ _commands_provider.boot()
@@ -170,4 +170,4 @@ class CommandsBootstrapper(ICommandsBootstrapper):
170
170
  """
171
171
  if signature is None:
172
172
  return self._commands
173
- return self._commands[signature]
173
+ return self._commands[signature] or {}
@@ -38,12 +38,6 @@ class Container(IContainer):
38
38
  cls._instance._validate_types = Types()
39
39
  return cls._instance
40
40
 
41
- def _newRequest(self) -> None:
42
- """
43
- Reset scoped instances at the beginning of a new request.
44
- """
45
- self._scoped_instances = {}
46
-
47
41
  def _ensureNotMain(self, concrete: Callable[..., Any]) -> str:
48
42
  """
49
43
  Ensure that a class is not defined in the main script.
@@ -117,6 +111,12 @@ class Container(IContainer):
117
111
  if not isinstance(instance, object) or instance.__class__.__module__ in ['builtins', 'abc']:
118
112
  raise OrionisContainerValueError(f"The instance '{str(instance)}' must be a valid object.")
119
113
 
114
+ def forgetScopedInstances(self) -> None:
115
+ """
116
+ Reset scoped instances at the beginning of a new request.
117
+ """
118
+ self._scoped_instances = {}
119
+
120
120
  def bind(self, concrete: Callable[..., Any]) -> str:
121
121
  """
122
122
  Bind a callable to the container.
@@ -1,6 +1,6 @@
1
1
  from typing import Any
2
2
  from orionis.luminate.container.container import Container
3
- from orionis.luminate.container.exception import OrionisContainerException, OrionisContainerTypeError
3
+ from orionis.luminate.container.exception import OrionisContainerTypeError
4
4
 
5
5
  def app(concrete: Any = None):
6
6
  """
@@ -33,8 +33,6 @@ def app(concrete: Any = None):
33
33
 
34
34
  # If concrete is provided (not None), attempt to resolve it from the container
35
35
  if concrete is not None:
36
- if not isinstance(concrete, type):
37
- raise OrionisContainerTypeError(f"The provided concrete must be a class or service, got {type(concrete)}.")
38
36
  return container.make(concrete)
39
37
 
40
38
  # If concrete is None, return the container instance
File without changes
@@ -0,0 +1,42 @@
1
+ from typing import Any
2
+ from orionis.contracts.facades.commands.i_commands_facade import ICommand
3
+ from orionis.luminate.facades.app import app
4
+ from orionis.luminate.services.commands.reactor_commands_service import ReactorCommandsService
5
+
6
+ class Command(ICommand):
7
+ """
8
+ Command class for managing and executing registered CLI commands.
9
+
10
+ This class provides a static method to invoke commands registered in the
11
+ `CacheCommands` singleton, passing the required signature and any additional
12
+ parameters.
13
+
14
+ Methods
15
+ -------
16
+ call(signature: str, vars: dict[str, Any] = {}, *args: Any, **kwargs: Any) -> Any
17
+ Executes the specified command with the provided arguments.
18
+ """
19
+
20
+ @staticmethod
21
+ def call(signature: str, vars: dict[str, Any] = {}, *args: Any, **kwargs: Any) -> Any:
22
+ """
23
+ Calls a registered command using the `CLIRunner`.
24
+
25
+ Parameters
26
+ ----------
27
+ signature : str
28
+ The command signature (name) to execute.
29
+ vars : dict[str, Any], optional
30
+ A dictionary containing named arguments for the command (default is `{}`).
31
+ *args : Any
32
+ Additional positional arguments.
33
+ **kwargs : Any
34
+ Additional keyword arguments.
35
+
36
+ Returns
37
+ -------
38
+ Any
39
+ The output of the executed command.
40
+ """
41
+ _commands_provider : ReactorCommandsService = app(ReactorCommandsService)
42
+ return _commands_provider.execute(signature, vars, *args, **kwargs)
File without changes
@@ -0,0 +1,19 @@
1
+ from orionis.luminate.providers.service_provider import ServiceProvider
2
+ from orionis.luminate.services.commands.reactor_commands_service import ReactorCommandsService
3
+
4
+ class ReactorCommandsServiceProvider(ServiceProvider):
5
+
6
+ def register(self) -> None:
7
+ """
8
+ Registers services or bindings into the given container.
9
+ """
10
+ self._container_id = self.app.singleton(ReactorCommandsService)
11
+
12
+ def boot(self,) -> None:
13
+ """
14
+ Boot the service provider.
15
+
16
+ This method is intended to be overridden by subclasses to perform
17
+ any necessary bootstrapping or initialization tasks.
18
+ """
19
+ self.app.make(self._container_id)
File without changes
@@ -0,0 +1,155 @@
1
+ import time
2
+ from typing import Any, Dict, Optional
3
+ from orionis.contracts.services.commands.i_reactor_commands_service import IReactorCommandsService
4
+ from orionis.luminate.bootstrap.command_bootstrapper import CommandsBootstrapper
5
+ from orionis.luminate.console.base.command import BaseCommand
6
+ from orionis.luminate.console.command_filter import CommandFilter
7
+ from orionis.luminate.console.exceptions.cli_exception import CLIOrionisException
8
+ from orionis.luminate.console.output.console import Console
9
+ from orionis.luminate.console.output.executor import Executor
10
+ from orionis.luminate.console.parser import Parser
11
+ from orionis.luminate.facades.app import app
12
+ from orionis.luminate.facades.log.log_facade import Log
13
+
14
+ class ReactorCommandsService(IReactorCommandsService):
15
+ """
16
+ Service responsible for executing and managing CLI commands in Orionis.
17
+
18
+ This service handles:
19
+ - Parsing command arguments.
20
+ - Executing commands and logging their output.
21
+ - Managing execution timing and error handling.
22
+ """
23
+
24
+ def __init__(
25
+ self,
26
+ commands_bootstrapper: CommandsBootstrapper,
27
+ command_filter: CommandFilter,
28
+ log: Log,
29
+ executor: Executor,
30
+ console: Console,
31
+ ):
32
+ """
33
+ Initializes the ReactorCommandsService instance.
34
+
35
+ Assigns provided services to internal attributes for later use in command
36
+ execution, filtering, and logging.
37
+ """
38
+ self.commands_bootstrapper = commands_bootstrapper
39
+ self.command_filter = command_filter
40
+ self.log = log
41
+ self.console_executor = executor
42
+ self.console_output = console
43
+
44
+ def _parse_arguments(
45
+ self, arguments, vars: Optional[Dict[str, Any]] = None, *args, **kwargs
46
+ ):
47
+ """
48
+ Parses command-line arguments using the Orionis argument parser.
49
+
50
+ Utilizes an internal parser to convert raw arguments into structured data.
51
+ Handles exceptions to ensure errors are properly raised and managed.
52
+ """
53
+ try:
54
+ arg_parser = Parser(vars=vars or {}, args=args, kwargs=kwargs)
55
+ arg_parser.setArguments(arguments=arguments)
56
+ arg_parser.recognize()
57
+ return arg_parser.get()
58
+ except Exception as e:
59
+ raise ValueError(f"Error parsing arguments: {e}")
60
+
61
+ def _extract_arguments(self, args_dict:Any):
62
+ """
63
+ Extracts the arguments from the provided dictionary.
64
+
65
+ Parameters
66
+ ----------
67
+ args_dict : Any
68
+ A dictionary containing the arguments to extract.
69
+ """
70
+ try:
71
+ return vars(args_dict)
72
+ except Exception as e:
73
+ raise ValueError(f"Error parsing arguments: {e}")
74
+
75
+ def _call(self, signature: str, args_dict: Any) -> Any:
76
+ """
77
+ Executes the specified command with the provided arguments.
78
+
79
+ Parameters
80
+ ----------
81
+ signature : str
82
+ The command signature (name) to execute.
83
+ args_dict : Any
84
+ A dictionary containing named arguments for the command.
85
+ """
86
+
87
+ command_instance: BaseCommand = app(signature)
88
+ command_instance.setArgs(args_dict)
89
+ return command_instance.handle(**self._extract_arguments(args_dict))
90
+
91
+ def execute(self, signature: Optional[str] = None, vars: dict = {}, *args, **kwargs):
92
+ """
93
+ Processes and executes a CLI command.
94
+
95
+ Determines if the command originates from `sys.argv` or is explicitly called,
96
+ then executes the appropriate command pipeline, handling success and errors.
97
+ """
98
+ try:
99
+
100
+ # Determine if command is excluded from running
101
+ exclude_running = self.command_filter.isExcluded(signature)
102
+ sys_argv = signature is None
103
+
104
+ # Start timing execution
105
+ start_time = time.perf_counter()
106
+
107
+ # Extract signature and arguments from command-line input
108
+ if sys_argv:
109
+ if not args or len(args[0]) <= 1:
110
+ raise CLIOrionisException("No command signature specified. Please provide a valid command to execute.")
111
+ args_list = args[0]
112
+ signature, *args = args_list[1:]
113
+
114
+ # Log command execution
115
+ self.log.info(f"Running command: {signature}")
116
+
117
+ # Notify console
118
+ if not exclude_running:
119
+ self.console_executor.running(program=signature)
120
+
121
+ # Retrieve command from bootstrapper
122
+ command = self.commands_bootstrapper.get(signature)
123
+
124
+ # Parse command arguments dynamically based on execution context
125
+ args_dict = self._parse_arguments(command.get('arguments', []), vars, *args, **kwargs)
126
+
127
+ # Exception handling for command execution
128
+ output = self._call(signature, args_dict)
129
+
130
+ # Log successful command execution
131
+ self.log.success(f"Command executed successfully: {signature}")
132
+
133
+ # Finalize execution and report elapsed time
134
+ if not exclude_running:
135
+ elapsed_time = round(time.perf_counter() - start_time, 2)
136
+ self.console_executor.done(program=signature, time=f"{elapsed_time}s")
137
+
138
+ # Return command output
139
+ return output
140
+
141
+ except ValueError as e:
142
+ # Handle parsing errors
143
+ self.log.error(f"Command failed: {signature or 'Unknown'}, Value Error: {e}")
144
+ if not exclude_running:
145
+ self.console_output.error(message=f"Value Error: {e}")
146
+ elapsed_time = round(time.perf_counter() - start_time, 2)
147
+ self.console_executor.fail(program=signature or "Unknown", time=f"{elapsed_time}s")
148
+
149
+ except Exception as e:
150
+ # Handle unexpected execution errors
151
+ self.log.error(f"Command failed: {signature or 'Unknown'}, Execution Error: {e}")
152
+ if not exclude_running:
153
+ self.console_output.error(message=f"Execution Error: {e}")
154
+ elapsed_time = round(time.perf_counter() - start_time, 2)
155
+ self.console_executor.fail(program=signature or "Unknown", time=f"{elapsed_time}s")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.80.0
3
+ Version: 0.84.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro
@@ -1,6 +1,6 @@
1
1
  orionis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  orionis/cli_manager.py,sha256=0bM-hABXJSoPGuvEgnqeaj9qcLP8VjTQ3z9Mb0TSEUI,1381
3
- orionis/framework.py,sha256=I1IFU4kjM_IdHGzyYiW4hp7PtIDRKZUsxIFUhdGsE4k,1386
3
+ orionis/framework.py,sha256=weWLOElszFX_SP5tDJ7CW2cmc0DET5KgviqJDFMIleY,1386
4
4
  orionis/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  orionis/contracts/bootstrap/i_command_bootstrapper.py,sha256=cfpYWSlNhOY1q_C9o0H7F381OoM0Oh0qaeqP-c85nzk,2457
6
6
  orionis/contracts/bootstrap/i_config_bootstrapper.py,sha256=d2TXT74H2fCBbzWgrt9-ZG11S_H_YPQOEcJoIOrsgb0,4462
@@ -20,9 +20,11 @@ orionis/contracts/console/output/i_executor.py,sha256=MGMTTPSwF8dgCjHD3A4CKtYDaC
20
20
  orionis/contracts/console/output/i_progress_bar.py,sha256=sOkQzQsliFemqZHMyzs4fWhNJfXDTk5KH3aExReetSE,1760
21
21
  orionis/contracts/console/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  orionis/contracts/console/tasks/i_schedule.py,sha256=_dsR0gCvJ7_67lwPUAzBwQFHNvWM6jVjcg1EdPqDIIo,10117
23
- orionis/contracts/container/i_container.py,sha256=c_QRQHXGIujiDnYXyt--3J2LKXngVtoB3O-qchPmFDQ,6899
23
+ orionis/contracts/container/i_container.py,sha256=MSJkVNawcovxSUAG-nrEctMYLT8H0OJq15pL5UwJeqA,6932
24
24
  orionis/contracts/container/i_types.py,sha256=GCH7x3PjpXKPET3l84GcXbcM8cpne8AGrmTw-uFaT24,526
25
25
  orionis/contracts/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ orionis/contracts/facades/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ orionis/contracts/facades/commands/i_commands_facade.py,sha256=LpSfZb3lTmhgMx0H42NmFbKLvcOqSDIbpQrkQpF9RPY,1274
26
28
  orionis/contracts/facades/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
29
  orionis/contracts/facades/config/i_config_facade.py,sha256=Yzc0mB4W9XF8cZTdTO78AKUiyGaiShl1k8nJiecvKTc,970
28
30
  orionis/contracts/facades/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -40,6 +42,8 @@ orionis/contracts/installer/i_installer_setup.py,sha256=enXOusaAJVWamTpH9FjXpJf-
40
42
  orionis/contracts/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
43
  orionis/contracts/providers/i_service_provider.py,sha256=zoBAsGE-KrNfCsF3u876oxoa518zMuBD9npRK7BixUs,791
42
44
  orionis/contracts/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
+ orionis/contracts/services/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
+ orionis/contracts/services/commands/i_reactor_commands_service.py,sha256=msIOfwOYASFNuS4shhwsnukPH5_XnuxNBHW9f6q-Lqo,795
43
47
  orionis/contracts/services/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
48
  orionis/contracts/services/config/i_config_service.py,sha256=TdlEEsd8jvzBGozwaZtQ9KYHisY4ACL-VUOtydidHeE,989
45
49
  orionis/contracts/services/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -56,10 +60,10 @@ orionis/installer/installer_manager.py,sha256=Hb6T0bmSl39T30maY-nUWkrLhG77JdrKe4
56
60
  orionis/installer/installer_output.py,sha256=LeKxzuXpnHOKbKpUtx3tMGkCi2bGcPV1VNnfBxwfxUU,7161
57
61
  orionis/installer/installer_setup.py,sha256=c2HtVklSa-2_-YVonc7fwtoK-RTDqBS2Ybvbekgfqtc,6970
58
62
  orionis/luminate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
- orionis/luminate/app.py,sha256=-s56Fvnsd5KZxwLZI2dNDI3ZuHcNpZU5Wq0XCzT1gJE,3484
63
+ orionis/luminate/app.py,sha256=GZccClZ3kvi9o5qLmBbKMLSZDPP9h0iiM5QlbTwonYw,11702
60
64
  orionis/luminate/app_context.py,sha256=XREVkOHU6aP8UB2daA2QbFcOCB8HRmcGXjVbrlW1AHQ,1827
61
65
  orionis/luminate/bootstrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
- orionis/luminate/bootstrap/command_bootstrapper.py,sha256=OU0hDMtG1xqVbvCneq4C5mlOUu9OmfkxqbvGH59QsUw,6919
66
+ orionis/luminate/bootstrap/command_bootstrapper.py,sha256=JJkWWOS2R2Zg7mC7-VMtZ0wAgxlegMkdnqudpbAjxwk,6925
63
67
  orionis/luminate/bootstrap/config_bootstrapper.py,sha256=Gw83UtPAOggwzqmz062JfJcpIfmZvmIQyZJfgVFiIcQ,7474
64
68
  orionis/luminate/bootstrap/environment_bootstrapper.py,sha256=GTZ-mBumoNlxYcqsQksw4XyH3TRfPkWAU62mB3wFKLk,2777
65
69
  orionis/luminate/bootstrap/exception_bootstrapper.py,sha256=wDKfEW295c7-bavr7YUHK2CLYcTSZgjT9ZRSBne6GOE,1356
@@ -79,7 +83,6 @@ orionis/luminate/console/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
79
83
  orionis/luminate/console/command_filter.py,sha256=os5BxR6Rcmihrv34pD-fFTkRms_nZzCIrV7vr4RNuIU,1322
80
84
  orionis/luminate/console/kernel.py,sha256=uh3IeR3qI3X0esyw9dxE0LzQ6ueSd_2suMijtQn3HWM,939
81
85
  orionis/luminate/console/parser.py,sha256=qif0eR54bwaVOiugVQh-NUks35XD2VofWbJlRpfR8lg,5579
82
- orionis/luminate/console/runner.py,sha256=7oLEZpJ4lPf4YkP9bj7wvgT9GJ2gUJv81JKXEdD0gA0,4820
83
86
  orionis/luminate/console/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
84
87
  orionis/luminate/console/base/command.py,sha256=YGHd5xVYILcNhQumi74IRnzvagvjufEO2Bx1CwHRToY,12544
85
88
  orionis/luminate/console/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -97,11 +100,13 @@ orionis/luminate/console/output/progress_bar.py,sha256=ssi8Drryr-shl7OxweTgGOhvR
97
100
  orionis/luminate/console/output/styles.py,sha256=2e1_FJdNpKaVqmdlCx-udzTleH_6uEFE9_TjH7T1ZUk,3696
98
101
  orionis/luminate/console/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
99
102
  orionis/luminate/console/tasks/scheduler.py,sha256=zt4p2VGUYGGrG2-E-MxyheKjBqGDJB2c0irULDsBgIw,22678
100
- orionis/luminate/container/container.py,sha256=RlGsAgUqSZa2bAvaxCtD3babXNUse7f3t9dDjz1scSg,16419
103
+ orionis/luminate/container/container.py,sha256=Ruyhs5OAiO6nMFhGDm7TNQD4qqFO0lh_phqUFDit_bE,16429
101
104
  orionis/luminate/container/exception.py,sha256=ap1SqYEjQEEHXJJTNmL7V1jrmRjgT5_7geZ95MYkhMA,1691
102
105
  orionis/luminate/container/types.py,sha256=BDcXN0__voRNHZ5Gr5dF0sWIYAQyNk4TxAwILBWyDAA,1735
103
106
  orionis/luminate/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
104
- orionis/luminate/facades/app.py,sha256=20ai-4ggQSBLNz2zpaESKsJ7NhnTQ-XvnRoT_WGNcxk,1486
107
+ orionis/luminate/facades/app.py,sha256=DHwCdhfU-Mfj0gPX5nwXR_cgnkvg6agMP2WBa-L0JE8,1294
108
+ orionis/luminate/facades/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
109
+ orionis/luminate/facades/commands/commands_facade.py,sha256=xy-5sW5_fDXhS2y0c0CCbBOfrOR0mJQLVTwBe3J8WTk,1561
105
110
  orionis/luminate/facades/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
106
111
  orionis/luminate/facades/config/config_facade.py,sha256=xpyVdH_-CeOvtMuf-Pjl9SFZWOflXzx9lyDy_fYOmxU,1353
107
112
  orionis/luminate/facades/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -114,10 +119,10 @@ orionis/luminate/facades/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
114
119
  orionis/luminate/facades/tests/tests_facade.py,sha256=eH_fyXjzEVw8aqEwxAgSujFUItz2woau6hc2Mf4VlkE,1660
115
120
  orionis/luminate/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
116
121
  orionis/luminate/patterns/singleton.py,sha256=b3U0nubKSQWyal5wTXADVPtOztkaTk-M8Zwy-bje1L0,1425
117
- orionis/luminate/pipelines/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
118
- orionis/luminate/pipelines/cli_pipeline.py,sha256=xpdwxArZrYqaeo4h375RQwY329V14S8DJC9z1w_Ar1s,4218
119
122
  orionis/luminate/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
120
123
  orionis/luminate/providers/service_provider.py,sha256=Ave9V10KPVCI6bt3HwJ51322P-_RnQuHXkC-ltlAOOA,1537
124
+ orionis/luminate/providers/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
125
+ orionis/luminate/providers/commands/reactor_commands_service_provider.py,sha256=3HX3wwPCH_Y9OsoTyfC4_LrNlPW_-UaffDcz3Wehuvk,701
121
126
  orionis/luminate/providers/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
122
127
  orionis/luminate/providers/config/config_service_provider.py,sha256=NLKB3Vcu4kqZ0WyeImMG3CsclSu_P4aWs6yXitcv474,659
123
128
  orionis/luminate/providers/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -125,6 +130,8 @@ orionis/luminate/providers/environment/environment__service_provider.py,sha256=L
125
130
  orionis/luminate/providers/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
126
131
  orionis/luminate/providers/log/log_service_provider.py,sha256=tcWDEI-fubi1mWSS-IKiRReuc0pRMHpxvbvuDgs2Uy0,654
127
132
  orionis/luminate/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
133
+ orionis/luminate/services/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
134
+ orionis/luminate/services/commands/reactor_commands_service.py,sha256=UgWBPsApDpZPJOqgMa0wd0v9H9ACOYtf8fOjiD3KpJw,6347
128
135
  orionis/luminate/services/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
129
136
  orionis/luminate/services/config/config_service.py,sha256=sVqX3UBxZA5whjiVFgfo5fzAb8QxD0NT0OYYlgZUK0g,2223
130
137
  orionis/luminate/services/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -153,9 +160,9 @@ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
153
160
  tests/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
154
161
  tests/tools/class_example.py,sha256=dIPD997Y15n6WmKhWoOFSwEldRm9MdOHTZZ49eF1p3c,1056
155
162
  tests/tools/test_reflection.py,sha256=bhLQ7VGVod4B8sv-rW9AjnOumvaBVsoxieA3sdoM2yM,5244
156
- orionis-0.80.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
157
- orionis-0.80.0.dist-info/METADATA,sha256=OG3pCfV-jo1_4JcCHxnqCVbbCzccudkBjAr-FqoOmyQ,2978
158
- orionis-0.80.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
159
- orionis-0.80.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
160
- orionis-0.80.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
161
- orionis-0.80.0.dist-info/RECORD,,
163
+ orionis-0.84.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
164
+ orionis-0.84.0.dist-info/METADATA,sha256=fpTYuip02QzdiMKwz0_XgzwBrcLt-KiHapU1vtRpmGE,2978
165
+ orionis-0.84.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
166
+ orionis-0.84.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
167
+ orionis-0.84.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
168
+ orionis-0.84.0.dist-info/RECORD,,
@@ -1,127 +0,0 @@
1
- # import time
2
- # from orionis.luminate.facades.log import Log
3
- # from orionis.luminate.console.output.console import Console
4
- # from orionis.luminate.console.output.executor import Executor
5
- # from orionis.luminate.pipelines.cli_pipeline import CLIPipeline
6
- # from orionis.luminate.console.command_filter import CommandFilter
7
- # from orionis.luminate.contracts.console.runner_interface import ICLIRunner
8
-
9
- class CLIRunner:
10
- pass
11
- # """
12
- # CLIRunner manages the execution of CLI commands in Orionis.
13
-
14
- # This class:
15
- # - Parses command-line arguments or function parameters.
16
- # - Executes commands through the `CLIPipeline`.
17
- # - Logs execution status and errors.
18
-
19
- # Methods
20
- # -------
21
- # handle(signature: str = None, vars: dict = {}, *args, **kwargs)
22
- # Processes and executes a CLI command based on provided arguments.
23
- # """
24
-
25
- # @staticmethod
26
- # def handle(signature: str = None, vars: dict = {}, *args, **kwargs):
27
- # """
28
- # Processes and executes a CLI command.
29
-
30
- # This method:
31
- # - Determines whether the command is invoked from `sys.argv` or as a function.
32
- # - Extracts the command signature and arguments.
33
- # - Executes the command pipeline.
34
- # - Logs execution status and handles errors.
35
-
36
- # Parameters
37
- # ----------
38
- # signature : str, optional
39
- # The command signature (default is None, meaning it is extracted from `sys.argv`).
40
- # vars : dict, optional
41
- # Named arguments for the command (default is an empty dictionary).
42
- # *args
43
- # Additional arguments for the command.
44
- # **kwargs
45
- # Additional keyword arguments for the command.
46
-
47
- # Returns
48
- # -------
49
- # Any
50
- # The output of the executed command.
51
-
52
- # Raises
53
- # ------
54
- # ValueError
55
- # If no command signature is provided.
56
- # Exception
57
- # If an unexpected error occurs during execution.
58
- # """
59
-
60
- # try:
61
-
62
- # # Exclude commands from Printing
63
- # exclude_running = CommandFilter.isExcluded(signature)
64
-
65
- # # Determine if command is being executed from sys.argv
66
- # sys_argv = signature is None
67
-
68
- # # Start execution timer
69
- # start_time = time.perf_counter()
70
-
71
- # # Handle command signature extraction from sys.argv
72
- # if sys_argv:
73
-
74
- # # Extract command signature and arguments from sys.argv
75
- # if not args or len(args[0]) <= 1:
76
- # raise ValueError("No command signature specified.")
77
-
78
- # # Extract command signature and arguments
79
- # args_list = args[0]
80
- # signature, *args = args_list[1:]
81
-
82
- # # Log command execution start
83
- # Log.info(f"Running command: {signature}")
84
-
85
- # if not exclude_running:
86
- # Executor.running(program=signature)
87
-
88
- # # Initialize command pipeline
89
- # pipeline = CLIPipeline().getCommand(signature)
90
-
91
- # # Parse arguments based on invocation type
92
- # if sys_argv:
93
- # pipeline.parseArguments(*args)
94
- # else:
95
- # pipeline.parseArguments(vars, *args, **kwargs)
96
-
97
- # # Execute the command
98
- # output = pipeline.execute()
99
-
100
- # # Log successful execution
101
- # Log.success(f"Command executed successfully: {signature}")
102
-
103
- # # Calculate execution time
104
- # if not exclude_running:
105
- # elapsed_time = round(time.perf_counter() - start_time, 2)
106
- # Executor.done(program=signature, time=f"{elapsed_time}s")
107
-
108
- # # Return command output
109
- # return output
110
-
111
- # except ValueError as e:
112
-
113
- # # Handle missing or invalid command signature
114
- # Log.error(f"Command failed: {signature or 'Unknown'}, Value Error: {e}")
115
- # if not exclude_running:
116
- # Console.error(message=f"Value Error: {e}")
117
- # elapsed_time = round(time.perf_counter() - start_time, 2)
118
- # Executor.fail(program=signature or "Unknown", time=f"{elapsed_time}s")
119
-
120
- # except Exception as e:
121
-
122
- # # Handle unexpected errors
123
- # Log.error(f"Command failed: {signature or 'Unknown'}, Execution Error: {e}")
124
- # if not exclude_running:
125
- # Console.error(message=f"Execution Error: {e}")
126
- # elapsed_time = round(time.perf_counter() - start_time, 2)
127
- # Executor.fail(program=signature or "Unknown", time=f"{elapsed_time}s")
@@ -1,122 +0,0 @@
1
- # import argparse
2
- # from typing import Dict, Any, Optional
3
- # from orionis.luminate.app_context import AppContext
4
- # from orionis.luminate.console.parser import Parser
5
- # from orionis.luminate.console.cache import CLICache
6
- # from orionis.luminate.console.base.command import BaseCommand
7
- # from orionis.luminate.contracts.pipelines.cli_pipeline_interface import ICLIPipeline
8
-
9
- class CLIPipeline:
10
- pass
11
- # """
12
- # Handles the retrieval, parsing, and execution of CLI commands within the Orionis framework.
13
-
14
- # This class is responsible for:
15
- # - Retrieving command metadata from cache.
16
- # - Parsing command-line arguments dynamically.
17
- # - Executing the corresponding command with parsed arguments.
18
-
19
- # Attributes
20
- # ----------
21
- # _command : dict
22
- # Stores the command's metadata, including its instance and expected arguments.
23
- # _parsed_arguments : argparse.Namespace
24
- # Holds parsed arguments after processing user input.
25
- # """
26
-
27
- # def __init__(self):
28
- # """
29
- # Initializes the CLIPipeline instance with an empty command cache
30
- # and a default argument namespace.
31
- # """
32
- # self._command: Dict[str, Any] = {}
33
- # self._parsed_arguments: argparse.Namespace = argparse.Namespace()
34
-
35
- # def getCommand(self, signature: str) -> "CLIPipeline":
36
- # """
37
- # Retrieves a command from the cache based on its signature.
38
-
39
- # Parameters
40
- # ----------
41
- # signature : str
42
- # The unique identifier of the command.
43
-
44
- # Returns
45
- # -------
46
- # CLIPipeline
47
- # The current instance of CLIPipeline for method chaining.
48
-
49
- # Raises
50
- # ------
51
- # ValueError
52
- # If the command signature is not found in the cache.
53
- # """
54
- # with AppContext() as app:
55
- # config_service : BaseCommand = app.container.run_command("config")
56
- # config_service.
57
-
58
- # try:
59
- # cache = CLICache().getCommands()
60
- # self._command = cache.get(signature)
61
- # return self
62
- # except KeyError as e:
63
- # raise ValueError(e)
64
-
65
- # def parseArguments(self, vars: Optional[Dict[str, Any]] = None, *args, **kwargs) -> "CLIPipeline":
66
- # """
67
- # Parses command-line arguments using the Orionis argument parser.
68
-
69
- # Parameters
70
- # ----------
71
- # vars : dict, optional
72
- # A dictionary of predefined variables to be included in parsing.
73
- # *args
74
- # Positional arguments for the parser.
75
- # **kwargs
76
- # Keyword arguments for the parser.
77
-
78
- # Returns
79
- # -------
80
- # CLIPipeline
81
- # The current instance of CLIPipeline for method chaining.
82
-
83
- # Raises
84
- # ------
85
- # ValueError
86
- # If an error occurs during argument parsing.
87
- # """
88
- # try:
89
- # arguments = self._command.get("arguments")
90
- # if arguments:
91
- # arg_parser = Parser(vars=vars or {}, args=args, kwargs=kwargs)
92
- # arg_parser.setArguments(arguments=arguments)
93
- # arg_parser.recognize()
94
- # self._parsed_arguments = arg_parser.get()
95
-
96
- # return self
97
-
98
- # except Exception as e:
99
- # raise ValueError(f"Error parsing arguments: {e}")
100
-
101
- # def execute(self) -> Any:
102
- # """
103
- # Executes the retrieved command using parsed arguments.
104
-
105
- # This method:
106
- # - Instantiates the command class.
107
- # - Calls the `handle()` method, passing the parsed arguments.
108
-
109
- # Returns
110
- # -------
111
- # Any
112
- # The output of the command execution.
113
-
114
- # Raises
115
- # ------
116
- # ValueError
117
- # If the command instance is invalid.
118
- # """
119
- # command_class = self._command.get("instance")
120
- # command_instance: BaseCommand = command_class()
121
- # command_instance.setArgs(self._parsed_arguments)
122
- # return command_instance.handle(**vars(self._parsed_arguments))