Skip to content

Commit a72bd99

Browse files
committed
feat: update commands with new version
1 parent a1b8451 commit a72bd99

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

bin/leaf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ $app = sprout()->createApp([
2121
]);
2222

2323
// $app->register(Leaf\Console\CreateCommand::class);
24+
// $app->register(Leaf\Console\UICommand::class);
2425
$app->register(Leaf\Console\UpdateCommand::class);
2526
$app->register(Leaf\Console\InstallCommand::class);
2627
$app->register(Leaf\Console\UninstallCommand::class);
2728
$app->register(Leaf\Console\ServeCommand::class);
2829
$app->register(Leaf\Console\InteractCommand::class);
2930
$app->register(Leaf\Console\RunCommand::class);
30-
$app->register(Leaf\Console\UICommand::class);
3131
$app->register(Leaf\Console\ViewBuildCommand::class);
3232
// $app->register(Leaf\Console\ViewInstallCommand::class);
3333

src/InstallCommand.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88

99
class InstallCommand extends Command
1010
{
11-
protected $signature = 'install {packages*} {--d|dev}';
11+
protected $signature = 'install {packages?*} {--d|dev=false : Install as a dev dependency}';
1212

1313
protected $description = 'Install a new package';
1414

15-
protected function execute(): int
15+
protected function handle(): int
1616
{
1717
$packages = $this->argument('packages');
18+
$parsedPackages = [];
1819

1920
if (count($packages)) {
2021
foreach ($packages as $package) {
@@ -25,14 +26,14 @@ protected function execute(): int
2526
$package = str_replace('@', ':', $package);
2627
$package = $this->option('dev') ? "$package --dev" : $package;
2728

28-
$this->writeln("<info>Installing $package...</info>");
29-
30-
if (!sprout()->composer()->install($package)->isSuccessful()) {
31-
return 1;
32-
}
29+
$parsedPackages[] = $package;
30+
}
3331

34-
$this->writeln("<comment>$package installed successfully!</comment>");
32+
if (!sprout()->composer()->install(implode(' ', $parsedPackages) . ' --ansi')->isSuccessful()) {
33+
return 1;
3534
}
35+
36+
return 0;
3637
}
3738

3839
return (int) sprout()->composer()->install()->isSuccessful();

src/RunCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class RunCommand extends Command
1010
{
11-
protected $signature = 'run {script!: Command to run.}';
11+
protected $signature = 'run {script : Command to run.}';
1212

1313
protected $description = 'Run a script in your composer.json';
1414

src/ServeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ServeCommand extends Command
1818
protected function handle(): int
1919
{
2020
if ($this->isMVCApp()) {
21-
return (int) sprout()->run("php leaf serve --ansi");
21+
return (int) sprout()->run("php leaf serve --port={$this->option('port')} --ansi", null);
2222
}
2323

2424
if (!sprout()->composer()->json()) {

src/UICommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class UICommand extends Command
1212

1313
protected $description = 'Open up the Leaf CLI GUI';
1414

15-
protected function execute(): int
15+
protected function handle(): int
1616
{
1717
$port = $this->option('port');
1818

src/UninstallCommand.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ class UninstallCommand extends Command
1212

1313
protected $description = 'Uninstall a package';
1414

15-
protected function execute(): int
15+
protected function handle(): int
1616
{
1717
$packages = $this->argument('packages');
18+
$parsedPackages = [];
1819

1920
if (!sprout()->composer()->json()) {
2021
$this->writeln('<error>No composer.json found in the current directory.</error>');
@@ -26,9 +27,11 @@ protected function execute(): int
2627
$package = "leafs/$package";
2728
}
2829

29-
if (!sprout()->composer()->remove($package)->isSuccessful()) {
30-
return 1;
31-
}
30+
$parsedPackages[] = $package;
31+
}
32+
33+
if (!sprout()->composer()->remove(implode(' ', $parsedPackages) . ' --ansi')->isSuccessful()) {
34+
return 1;
3235
}
3336

3437
$this->writeln('<comment>packages uninstalled successfully!</comment>');

0 commit comments

Comments
 (0)