File tree Expand file tree Collapse file tree 3 files changed +54
-0
lines changed
Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace NeuronAI \Console \Make ;
6+
7+ use RuntimeException ;
8+
9+ use function file_get_contents ;
10+ use function str_replace ;
11+
12+ class MakeEventCommand extends MakeCommand
13+ {
14+ public function __construct ()
15+ {
16+ parent ::__construct ('Event ' );
17+ }
18+
19+ protected function getStubContent (string $ namespace , string $ className ): string
20+ {
21+ $ stubPath = __DIR__ . '/Stubs/event.stub ' ;
22+ $ stub = file_get_contents ($ stubPath );
23+
24+ if ($ stub === false ) {
25+ throw new RuntimeException ("Failed to read stub file: {$ stubPath }" );
26+ }
27+
28+ return str_replace (
29+ ['[namespace] ' , '[classname] ' ],
30+ [$ namespace , $ className ],
31+ $ stub
32+ );
33+ }
34+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare(strict_types=1);
4+
5+ namespace [namespace];
6+
7+ use NeuronAI\Workflow\Events\Event;
8+
9+ class [classname] implements Event
10+ {
11+ /**
12+ * Add class properties to carry custom data.
13+ */
14+ public function __construct()
15+ {
16+ }
17+ }
Original file line number Diff line number Diff line change 66
77use NeuronAI \Console \Evaluation \EvaluationCommand ;
88use NeuronAI \Console \Make \MakeAgentCommand ;
9+ use NeuronAI \Console \Make \MakeEventCommand ;
910use NeuronAI \Console \Make \MakeMiddlewareCommand ;
1011use NeuronAI \Console \Make \MakeNodeCommand ;
1112use NeuronAI \Console \Make \MakeRagCommand ;
@@ -29,6 +30,7 @@ class NeuronCli
2930 'make:tool ' => MakeToolCommand::class,
3031 'make:rag ' => MakeRagCommand::class,
3132 'make:workflow ' => MakeWorkflowCommand::class,
33+ 'make:event ' => MakeEventCommand::class,
3234 ];
3335
3436 /**
@@ -87,6 +89,7 @@ private function printUsage(): void
8789 make:tool Create a new Tool class
8890 make:rag Create a new RAG class
8991 make:workflow Create a new Workflow class
92+ make:event Create a new Event class
9093
9194Options:
9295 --help, -h Show this help message
You can’t perform that action at this time.
0 commit comments