Skip to content

Commit e92bed2

Browse files
Artisan::call('make:command') added
1 parent c6ac7e3 commit e92bed2

File tree

3 files changed

+26
-35
lines changed

3 files changed

+26
-35
lines changed

Capsule/Artisan.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,34 +75,6 @@ public static function call(string $input): int
7575
return $artisan->run($argv);
7676
}
7777

78-
/**
79-
* Split a command string into tokens while respecting quotes.
80-
*/
81-
private static function tokenizeCommand(string $input): array
82-
{
83-
$input = trim($input);
84-
if ($input === '') {
85-
return [];
86-
}
87-
88-
$tokens = [];
89-
// Match: "double-quoted" | 'single-quoted' | unquoted\-chunks
90-
$pattern = '/"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'|(\\S+)/';
91-
if (preg_match_all($pattern, $input, $matches, PREG_SET_ORDER)) {
92-
foreach ($matches as $m) {
93-
if (($m[1] ?? '') !== '') {
94-
$tokens[] = stripcslashes($m[1]);
95-
} elseif (($m[2] ?? '') !== '') {
96-
$tokens[] = stripcslashes($m[2]);
97-
} else {
98-
$tokens[] = $m[3];
99-
}
100-
}
101-
}
102-
103-
return $tokens;
104-
}
105-
10678
/**
10779
* Register a command by name with description
10880
*

Capsule/Traits/ArtisanDiscovery.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,33 @@ trait ArtisanDiscovery
2828
private static array $registeredProviders = [];
2929

3030

31+
/**
32+
* Split a command string into tokens while respecting quotes.
33+
*/
34+
private static function tokenizeCommand(string $input): array
35+
{
36+
$input = trim($input);
37+
if ($input === '') {
38+
return [];
39+
}
3140

41+
$tokens = [];
42+
// Match: "double-quoted" | 'single-quoted' | unquoted\-chunks
43+
$pattern = '/"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'|(\\S+)/';
44+
if (preg_match_all($pattern, $input, $matches, PREG_SET_ORDER)) {
45+
foreach ($matches as $m) {
46+
if (($m[1] ?? '') !== '') {
47+
$tokens[] = stripcslashes($m[1]);
48+
} elseif (($m[2] ?? '') !== '') {
49+
$tokens[] = stripcslashes($m[2]);
50+
} else {
51+
$tokens[] = $m[3];
52+
}
53+
}
54+
}
55+
56+
return $tokens;
57+
}
3258

3359
/**
3460
* Discover providers by scanning vendor composer.json

Commands/MakeCommand.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ class MakeCommand extends CommandHelper
1818
*/
1919
public function handle()
2020
{
21-
22-
dd(
23-
'ss',
24-
Artisan::call('make:command')
25-
);
26-
27-
exit();
2821
Logger::helpHeader('<yellow>Usage:</yellow>');
2922
Logger::writeln(' php tame make:command [name] --path=users');
3023
Logger::writeln('');

0 commit comments

Comments
 (0)