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

Commit 156b939

Browse files
committed
Merge branch 'master' into 5.1
2 parents 6ebb7a8 + 6cec1bf commit 156b939

File tree

9 files changed

+387
-8
lines changed

9 files changed

+387
-8
lines changed

TODO.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
- [ ] Change namespace using CLI
1010
- > By extending `Illuminate\Foundation\Console\AppNameCommand`
1111
- [ ] Listing
12-
- [ ] Services
13-
- [ ] Features (per service, and across all services)
12+
- [x] Services
13+
- [x] Features (per service, and across all services)
1414
- [ ] Jobs per feature
15+
- [ ] Domains
1516
- [ ] Pretty Interface

src/Commands/FeaturesListCommand.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the lucid-console project.
5+
*
6+
* (c) Vinelab <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Lucid\Console\Commands;
13+
14+
use Lucid\Console\Finder;
15+
use Illuminate\Console\Command;
16+
use Symfony\Component\Console\Input\InputArgument;
17+
18+
/**
19+
* @author Abed Halawi <[email protected]>
20+
*/
21+
class FeaturesListCommand extends Command
22+
{
23+
use Finder;
24+
25+
/**
26+
* The console command name.
27+
*
28+
* @var string
29+
*/
30+
protected $name = 'list:features';
31+
32+
/**
33+
* The console command description.
34+
*
35+
* @var string
36+
*/
37+
protected $description = 'List the services in this project.';
38+
39+
public function fire()
40+
{
41+
foreach ($this->listFeatures($this->argument('service')) as $service => $features) {
42+
$this->comment("\n$service\n");
43+
$this->table(['Feature', 'Service', 'File', 'Path'], $features);
44+
}
45+
}
46+
47+
/**
48+
* Get the console command arguments.
49+
*
50+
* @return array
51+
*/
52+
protected function getArguments()
53+
{
54+
return [
55+
['service', InputArgument::OPTIONAL, 'The service to list the features of.'],
56+
];
57+
}
58+
}

src/Commands/ServicesListCommand.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the lucid-console project.
5+
*
6+
* (c) Vinelab <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Lucid\Console\Commands;
13+
14+
use Lucid\Console\Finder;
15+
use Illuminate\Console\Command;
16+
17+
/**
18+
* @author Abed Halawi <[email protected]>
19+
*/
20+
class ServicesListCommand extends Command
21+
{
22+
use Finder;
23+
24+
/**
25+
* The console command name.
26+
*
27+
* @var string
28+
*/
29+
protected $name = 'list:services';
30+
31+
/**
32+
* The console command description.
33+
*
34+
* @var string
35+
*/
36+
protected $description = 'List the services in this project.';
37+
38+
public function fire()
39+
{
40+
$this->table(['Service', 'Slug', 'Path'], $this->listServices());
41+
}
42+
}

src/Components/Component.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the lucid-console project.
5+
*
6+
* (c) Vinelab <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Lucid\Console\Components;
13+
14+
use Illuminate\Contracts\Support\Arrayable;
15+
16+
class Component implements Arrayable
17+
{
18+
protected $attributes = [];
19+
20+
/**
21+
* Get the array representation of this instance.
22+
*
23+
* @return array
24+
*/
25+
public function toArray()
26+
{
27+
return $this->attributes;
28+
}
29+
30+
/**
31+
* Set the attributes for this component.
32+
*
33+
* @param array $attributes
34+
*/
35+
protected function setAttributes(array $attributes)
36+
{
37+
$this->attributes = $attributes;
38+
}
39+
40+
/**
41+
* Get an attribute's value if found.
42+
*
43+
* @param string $key
44+
*
45+
* @return mixed
46+
*/
47+
public function __get($key)
48+
{
49+
if (isset($this->attributes[$key])) {
50+
return $this->attributes[$key];
51+
}
52+
}
53+
54+
}

src/Components/Feature.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the lucid-console project.
5+
*
6+
* (c) Vinelab <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Lucid\Console\Components;
13+
14+
/**
15+
* @author Abed Halawi <[email protected]>
16+
*/
17+
class Feature extends Component
18+
{
19+
public function __construct($title, $file, $realPath, $relativePath, Service $service)
20+
{
21+
$this->setAttributes([
22+
'title' => $title,
23+
'service' => $service,
24+
'file' => $file,
25+
'realPath' => $realPath,
26+
'relativePath' => $relativePath,
27+
]);
28+
}
29+
30+
public function toArray()
31+
{
32+
$attributes = parent::toArray();
33+
34+
// real path not needed
35+
unset($attributes['realPath']);
36+
37+
// map the service object to its name
38+
$attributes['service'] = $attributes['service']->name;
39+
40+
return $attributes;
41+
}
42+
}

src/Components/Service.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the lucid-console project.
5+
*
6+
* (c) Vinelab <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Lucid\Console\Components;
13+
14+
/**
15+
* @author Abed Halawi <[email protected]>
16+
*/
17+
class Service extends Component
18+
{
19+
public function __construct($name, $realPath, $relativePath)
20+
{
21+
$this->setAttributes([
22+
'name' => $name,
23+
'slug' => snake_case($name),
24+
'realPath' => $realPath,
25+
'relativePath' => $relativePath,
26+
]);
27+
}
28+
29+
public function toArray()
30+
{
31+
$attributes = parent::toArray();
32+
33+
unset($attributes['realPath']);
34+
35+
return $attributes;
36+
}
37+
}

0 commit comments

Comments
 (0)