Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

Commit b30437c

Browse files
committed
fix listing services and features in CLI
1 parent e32152c commit b30437c

File tree

4 files changed

+34
-18
lines changed

4 files changed

+34
-18
lines changed

src/Commands/FeatureMakeCommand.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111

1212
namespace Lucid\Console\Commands;
1313

14-
use Lucid\Console\Str;
15-
use Lucid\Console\Finder;
16-
use Lucid\Console\Filesystem;
1714
use Illuminate\Console\GeneratorCommand;
15+
use Lucid\Console\Filesystem;
16+
use Lucid\Console\Finder;
17+
use Lucid\Console\Generators\FeatureGenerator;
18+
use Lucid\Console\Str;
1819
use Symfony\Component\Console\Input\InputArgument;
1920

2021
/**
@@ -53,13 +54,22 @@ class FeatureMakeCommand extends GeneratorCommand
5354
*/
5455
public function fire()
5556
{
56-
$service = studly_case($this->argument('service'));
57-
$feature = $this->parseName($this->argument('feature'));
57+
try {
58+
$service = studly_case($this->argument('service'));
59+
$title = $this->parseName($this->argument('feature'));
60+
61+
$generator = app(FeatureGenerator::class);
62+
$feature = $generator->generate($title, $service);
5863

59-
$this->info('Feature class '.$feature.' created successfully.'.
60-
"\n".
61-
"\n".
62-
'Find it at <comment>'.strstr($path, 'src/').'</comment>'."\n");
64+
$this->info(
65+
'Feature class '.$feature->title.' created successfully.'.
66+
"\n".
67+
"\n".
68+
'Find it at <comment>'.strstr($feature->relativePath, 'src/').'</comment>'."\n"
69+
);
70+
} catch (Exception $e) {
71+
$this->error($e->getMessage());
72+
}
6373
}
6474

6575
/**
@@ -90,7 +100,7 @@ protected function getStub()
90100
* remove the Feature.php suffix if found
91101
* we're adding it ourselves.
92102
*
93-
* @param string $name
103+
* @param string $name
94104
*
95105
* @return string
96106
*/

src/Commands/FeaturesListCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public function fire()
4545
{
4646
foreach ($this->listFeatures($this->argument('service')) as $service => $features) {
4747
$this->comment("\n$service\n");
48+
$features = array_map(function($feature) {
49+
return [$feature->title, $feature->service->name, $feature->file, $feature->relativePath];
50+
}, $features->all());
4851
$this->table(['Feature', 'Service', 'File', 'Path'], $features);
4952
}
5053
}

src/Commands/JobMakeCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ public function fire()
6060
$title = $this->parseName($this->argument('job'));
6161

6262
try {
63-
6463
$job = $generator->generate($title, $domain);
6564

66-
$this->info('Job class '.$title.' created successfully.'.
67-
"\n".
68-
"\n".
69-
'Find it at <comment>'.$job->relativePath.'</comment>'."\n");
70-
65+
$this->info(
66+
'Job class '.$title.' created successfully.'.
67+
"\n".
68+
"\n".
69+
'Find it at <comment>'.$job->relativePath.'</comment>'."\n"
70+
);
7171
} catch (Exception $e) {
7272
$this->error($e->getMessage());
7373
}
@@ -96,7 +96,7 @@ public function getStub()
9696
* remove the Job.php suffix if found
9797
* we're adding it ourselves.
9898
*
99-
* @param string $name
99+
* @param string $name
100100
*
101101
* @return string
102102
*/

src/Commands/ServicesListCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class ServicesListCommand extends Command
3737

3838
public function fire()
3939
{
40-
$this->table(['Service', 'Slug', 'Path'], $this->listServices());
40+
$services = $this->listServices()->all();
41+
$this->table(['Service', 'Slug', 'Path'], array_map(function($service) {
42+
return [$service->name, $service->slug, $service->relativePath];
43+
}, $services));
4144
}
4245
}

0 commit comments

Comments
 (0)