orionis 0.625.0__py3-none-any.whl → 0.627.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.
@@ -0,0 +1,130 @@
1
+ from pathlib import Path
2
+ import re
3
+ from typing import List
4
+ from orionis.console.args.argument import CLIArgument
5
+ from orionis.console.base.command import BaseCommand
6
+ from orionis.console.contracts.reactor import IReactor
7
+ from orionis.console.exceptions import CLIOrionisRuntimeError
8
+ from rich.console import Console
9
+ from rich.panel import Panel
10
+
11
+ from orionis.foundation.contracts.application import IApplication
12
+
13
+ class MakeCommand(BaseCommand):
14
+ """
15
+ Command class to display usage information for the Orionis CLI.
16
+ """
17
+
18
+ # Indicates whether timestamps will be shown in the command output
19
+ timestamps: bool = False
20
+
21
+ # Command signature and description
22
+ signature: str = "make:command"
23
+
24
+ # Command description
25
+ description: str = "Creates a new custom console command for the Orionis CLI."
26
+
27
+ async def options(self) -> List[CLIArgument]:
28
+ """
29
+ Defines the command-line options available for the `make:command` command.
30
+
31
+ This method specifies the arguments that can be passed to the command when it is invoked
32
+ from the CLI. It includes both required and optional arguments, each represented as a
33
+ `CLIArgument` instance.
34
+
35
+ Returns
36
+ -------
37
+ List[CLIArgument]
38
+ A list of `CLIArgument` objects representing the available command-line options.
39
+ """
40
+
41
+ return [
42
+ CLIArgument(
43
+ flags=["name"],
44
+ type=str,
45
+ required=True,
46
+ help="The filename where the new command will be created."
47
+ ),
48
+ CLIArgument(
49
+ flags=["--signature", "-s"],
50
+ type=str,
51
+ required=False,
52
+ help="The signature for the new command."
53
+ ),
54
+ ]
55
+
56
+ def handle(self, app: IApplication) -> dict:
57
+ """
58
+ Handles the creation of a new custom console command file.
59
+
60
+ This method processes the user-provided arguments, validates them, loads a command stub template,
61
+ replaces placeholders with the appropriate values, and writes the resulting code to a new file
62
+ in the commands directory. It also ensures that the file does not already exist and provides
63
+ feedback to the user regarding the operation's success or failure.
64
+
65
+ Parameters
66
+ ----------
67
+ app : IApplication
68
+ The application instance used to resolve paths and interact with the application environment.
69
+
70
+ Returns
71
+ -------
72
+ dict
73
+ An empty dictionary. The method's primary purpose is side effects (file creation and user feedback).
74
+ """
75
+
76
+ try:
77
+
78
+ # Print a new line to separate output
79
+ self.newLine()
80
+
81
+ # Retrieve the 'name' argument (required) and 'signature' argument (optional, with default)
82
+ name: str = self.argument("name")
83
+ signature: str = self.argument("signature", "custom:command")
84
+
85
+ # Validate that the name argument is provided
86
+ if not name:
87
+ self.error("The 'name' argument is required.")
88
+
89
+ # Validate that the file name starts with a lowercase letter and contains only lowercase letters, numbers, or underscores
90
+ if not re.match(r'^[a-z][a-z0-9_]*$', name):
91
+ self.error("The 'name' argument must start with a lowercase letter and contain only lowercase letters, numbers, and underscores (_).")
92
+
93
+ # Validate the command signature: must start with a lowercase letter, can contain lowercase letters, numbers (not at the start), and the special characters ':' and '_'
94
+ if not re.match(r'^[a-z][a-z0-9_:]*$', signature):
95
+ self.error("The 'signature' argument must start with a lowercase letter and can only contain lowercase letters, numbers (not at the start), and the special characters ':' and '_'.")
96
+
97
+ # Load the command stub template from the stubs directory
98
+ stub_path = Path(__file__).parent.parent / "stubs" / "command.stub"
99
+ with open(stub_path, "r", encoding="utf-8") as file:
100
+ stub = file.read()
101
+
102
+ # Generate the class name by capitalizing each word and appending 'Command'
103
+ class_name = ''.join(word.capitalize() for word in name.split('_')) + "Command"
104
+ # Replace placeholders in the stub with the actual class name and signature
105
+ stub = stub.replace("{{class_name}}", class_name)
106
+ stub = stub.replace("{{signature}}", signature)
107
+
108
+ # Ensure the commands directory exists
109
+ commands_dir = app.path('console') / "commands"
110
+ commands_dir.mkdir(parents=True, exist_ok=True)
111
+ file_path = commands_dir / f"{name}.py"
112
+
113
+ # Check if the file already exists to prevent overwriting
114
+ if file_path.exists():
115
+ file_path = file_path.relative_to(app.path('root'))
116
+ self.error(f"The file [{file_path}] already exists. Please choose another name.")
117
+ else:
118
+ # Write the generated command code to the new file
119
+ with open(file_path, "w", encoding="utf-8") as file:
120
+ file.write(stub)
121
+ file_path = file_path.relative_to(app.path('root'))
122
+ self.info(f"Console command [{file_path}] created successfully.")
123
+
124
+ # Print a new line to separate output
125
+ self.newLine()
126
+
127
+ except Exception as e:
128
+
129
+ # Catch any unexpected exceptions and raise a CLI-specific runtime error
130
+ raise CLIOrionisRuntimeError(f"An unexpected error occurred: {e}") from e
@@ -288,7 +288,7 @@ class Reactor(IReactor):
288
288
  from orionis.console.commands.cache import CacheClearCommand
289
289
  from orionis.console.commands.scheduler_work import ScheduleWorkCommand
290
290
  from orionis.console.commands.scheduler_list import ScheduleListCommand
291
- from orionis.console.commands.make_listener import MakeListenerCommand
291
+ from orionis.console.commands.make_command import MakeCommand
292
292
 
293
293
  # List of core command classes to load (extend this list as more core commands are added)
294
294
  core_commands = [
@@ -300,7 +300,7 @@ class Reactor(IReactor):
300
300
  CacheClearCommand,
301
301
  ScheduleWorkCommand,
302
302
  ScheduleListCommand,
303
- MakeListenerCommand
303
+ MakeCommand
304
304
  ]
305
305
 
306
306
  # Iterate through the core command classes and register them
@@ -0,0 +1,31 @@
1
+ from orionis.console.base.command import BaseCommand
2
+ from orionis.console.args.argument import CLIArgument
3
+ from typing import List
4
+
5
+ class {{class_name}}(BaseCommand):
6
+ """
7
+ [Command objective]
8
+ """
9
+
10
+ # Command signature
11
+ signature: str = "{{signature}}"
12
+
13
+ # Command description
14
+ description: str = "[Command description]"
15
+
16
+ def options(cls) -> List[CLIArgument]:
17
+ """
18
+ Define the command's arguments and options.
19
+ Returns a list of CLIArgument instances.
20
+ """
21
+ return []
22
+
23
+ async def handle(self) -> None:
24
+ """
25
+ Implement the command logic here.
26
+ You can access arguments using self.argument("name").
27
+ """
28
+ try:
29
+ pass
30
+ except Exception as e:
31
+ raise e
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.625.0"
8
+ VERSION = "0.627.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orionis
3
- Version: 0.625.0
3
+ Version: 0.627.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
@@ -10,7 +10,7 @@ orionis/console/base/scheduler_event_listener.py,sha256=X2mZBAYLBCtLOH7QSrCEaLeJ
10
10
  orionis/console/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  orionis/console/commands/cache.py,sha256=d-J6Qu5Xpp9z0BU4OOb--gp9zWfUZOWm_LEBKIO8k-o,2321
12
12
  orionis/console/commands/help.py,sha256=0VQLw_8ghyMIbWH9L6S2I5umwa_rniK1lzDdX0qYS_U,3118
13
- orionis/console/commands/make_listener.py,sha256=vuXKOPIw_7MbiGwHGiDjLyd5-OqyBov1LKozsv2itEc,1801
13
+ orionis/console/commands/make_command.py,sha256=4sjQ_z5jLCl-fEmkiwkM7vkSA964Xx9tijL7YcFkLck,5782
14
14
  orionis/console/commands/publisher.py,sha256=m-4RGDI3gc3-ED7Pl0rASLcoZP694q9jNKq0vRMM9uA,21380
15
15
  orionis/console/commands/scheduler_list.py,sha256=OU9qOjZNZRRElxwpg-E8nVefJToeiWu2E2l8P17NZtI,4759
16
16
  orionis/console/commands/scheduler_work.py,sha256=YYKqGLI5crJKuyVjCVwO1ZY_ZxlTWFr1eoz0bQUvyXU,5919
@@ -32,7 +32,7 @@ orionis/console/contracts/reactor.py,sha256=iT6ShoCutAWEeJzOf_PK7CGXi9TgrOD5tewH
32
32
  orionis/console/contracts/schedule.py,sha256=xtXgp4BPhvhg3YSM4mrIdbyoBdr4OJBi1gBM_kJN5UQ,13694
33
33
  orionis/console/contracts/schedule_event_listener.py,sha256=h06qsBxuEMD3KLSyu0JXdUDHlQW19BX9lA09Qrh2QXg,3818
34
34
  orionis/console/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- orionis/console/core/reactor.py,sha256=6scyrKukt6BEcLBxIrfAKA8QYnvNTl2dXePw6IWGPUw,43831
35
+ orionis/console/core/reactor.py,sha256=pnjL2MdqNLhhlfpVYC9tCGWO4ZjlrIS4ixNGk9PY7DU,43814
36
36
  orionis/console/dumper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  orionis/console/dumper/debug.py,sha256=p8uflSXeDJDrVM9mZY4JMYEus73Z6TsLnQQtgP0QUak,22427
38
38
  orionis/console/dynamic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -61,8 +61,8 @@ orionis/console/output/console.py,sha256=EtSDWRBW8wk0iJdPfB1mzU49krLJBaSAUdVdVOz
61
61
  orionis/console/output/executor.py,sha256=uQjFPOlyZLFj9pcyYPugCqxwJog0AJgK1OcmQH2ELbw,7314
62
62
  orionis/console/request/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
63
  orionis/console/request/cli_request.py,sha256=lO7088xlVK1VP-NhCIgAo7qXGzCW3nXVOJag43fUv20,13207
64
- orionis/console/stub/command.stub,sha256=IfQ0bTrpataVFcT1ZdHyyiYNZ67D5Aox_QvgVJLeJnI,1240
65
- orionis/console/stub/listener.stub,sha256=DbX-ghx2-vb73kzQ6L20lyg5vSKn58jSLTwFuwNQU9k,4331
64
+ orionis/console/stubs/command.stub,sha256=ABQ2eFxJ0u0DvTfmoO_DdECkBy-rie-woG62G2Gxw8Y,805
65
+ orionis/console/stubs/listener.stub,sha256=DbX-ghx2-vb73kzQ6L20lyg5vSKn58jSLTwFuwNQU9k,4331
66
66
  orionis/console/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
67
  orionis/console/tasks/schedule.py,sha256=ZeeuQ9Tbu5KNowKC5oIk7yWeJXzlDQiQ278mWEgoCXc,87989
68
68
  orionis/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -216,7 +216,7 @@ orionis/foundation/providers/scheduler_provider.py,sha256=IrPQJwvQVLRm5Qnz0Cxon4
216
216
  orionis/foundation/providers/testing_provider.py,sha256=eI1p2lUlxl25b5Z487O4nmqLE31CTDb4c3Q21xFadkE,1615
217
217
  orionis/foundation/providers/workers_provider.py,sha256=GdHENYV_yGyqmHJHn0DCyWmWId5xWjD48e6Zq2PGCWY,1674
218
218
  orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
219
- orionis/metadata/framework.py,sha256=IUzbmVQgudOKc9b_rqMAxApxsx57n8g2ZIwHE4IR4nQ,4089
219
+ orionis/metadata/framework.py,sha256=c9JAamq8zVc7UugmpWAQ31X-LdFKRzq0Oied_NpUoqY,4089
220
220
  orionis/metadata/package.py,sha256=k7Yriyp5aUcR-iR8SK2ec_lf0_Cyc-C7JczgXa-I67w,16039
221
221
  orionis/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
222
222
  orionis/services/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -403,8 +403,8 @@ orionis/test/validators/workers.py,sha256=rWcdRexINNEmGaO7mnc1MKUxkHKxrTsVuHgbnI
403
403
  orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
404
404
  orionis/test/view/render.py,sha256=R55ykeRs0wDKcdTf4O1YZ8GDHTFmJ0IK6VQkbJkYUvo,5571
405
405
  orionis/test/view/report.stub,sha256=QLqqCdRoENr3ECiritRB3DO_MOjRQvgBh5jxZ3Hs1r0,28189
406
- orionis-0.625.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
407
- orionis-0.625.0.dist-info/METADATA,sha256=q1ztZyJ9RrzH5jtITrEtKrpmpRmTOdI5iSgkK0qOau8,4772
408
- orionis-0.625.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
409
- orionis-0.625.0.dist-info/top_level.txt,sha256=lyXi6jArpqJ-0zzNqd_uwsH-z9TCEBVBL-pC3Ekv7hU,8
410
- orionis-0.625.0.dist-info/RECORD,,
406
+ orionis-0.627.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
407
+ orionis-0.627.0.dist-info/METADATA,sha256=PrIbWXNzer85VG0nm79qdQSPwfnhOuIS2MVspWEUhrM,4772
408
+ orionis-0.627.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
409
+ orionis-0.627.0.dist-info/top_level.txt,sha256=lyXi6jArpqJ-0zzNqd_uwsH-z9TCEBVBL-pC3Ekv7hU,8
410
+ orionis-0.627.0.dist-info/RECORD,,
@@ -1,54 +0,0 @@
1
- from orionis.console.base.command import BaseCommand
2
- from orionis.console.exceptions import CLIOrionisRuntimeError
3
-
4
- class MakeListenerCommand(BaseCommand):
5
- """
6
- Este comando se encarga de crear los listener tando para CLI como para otro tipo de Eventos.
7
- """
8
-
9
- # Indicates whether timestamps will be shown in the command output
10
- timestamps: bool = False
11
-
12
- # Command signature and description
13
- signature: str = "make:listener"
14
-
15
- # Command description
16
- description: str = "Displays usage information, examples, and a list of available commands in the Orionis CLI."
17
-
18
- def handle(self) -> dict:
19
- """
20
- Displays usage information and a list of available commands for the Orionis CLI.
21
-
22
- Parameters
23
- ----------
24
- reactor : IReactor
25
- The reactor instance providing command metadata via the `info()` method.
26
-
27
- Returns
28
- -------
29
- dict
30
- A dictionary containing the list of available commands, each with its signature and description.
31
-
32
- Raises
33
- ------
34
- CLIOrionisRuntimeError
35
- If an unexpected error occurs during help information generation or display.
36
- """
37
- try:
38
-
39
- # Solicitar el nombre del listener al usuario
40
- ans = self.choice(
41
- question="Tipo de Listener",
42
- choices=[
43
- "Listener para eventos CLI",
44
- "Listener para eventos de Schedule",
45
- ],
46
- default_index=0
47
- )
48
-
49
- print(ans)
50
-
51
- except Exception as e:
52
-
53
- # Raise a custom runtime error if any exception occurs
54
- raise CLIOrionisRuntimeError(f"An unexpected error occurred: {e}") from e
@@ -1,42 +0,0 @@
1
- from orionis.console.base.command import BaseCommand
2
- from orionis.console.args.argument import CLIArgument
3
- from orionis.console.exceptions import CLIOrionisRuntimeError
4
-
5
- class {{class_name}}(BaseCommand):
6
- """
7
- Command: {{signature}}
8
- {{description}}
9
- """
10
-
11
- # Enable timestamps
12
- timestamps: bool = True
13
-
14
- # Command signature
15
- signature: str = "{{signature}}"
16
-
17
- # Command description
18
- description: str = "{{description}}"
19
-
20
- # Arguments (edit as needed)
21
- arguments = [
22
- CLIArgument(
23
- flags=["--example", "-e"],
24
- type=str,
25
- help="Example argument for {{class_name}}",
26
- default=None,
27
- required=False,
28
- metavar="EXAMPLE",
29
- dest="example",
30
- action="store",
31
- ),
32
- ]
33
-
34
- async def handle(self, *args, **kwargs) -> None:
35
- try:
36
- self.textSuccessBold("{{class_name}} executed successfully!")
37
- example_value = self.argument("example")
38
- if example_value:
39
- self.info(f"Received argument: {example_value}")
40
-
41
- except Exception as e:
42
- raise CLIOrionisRuntimeError(f"An error occurred: {str(e)}") from e
File without changes