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

Commit

Permalink
list services and features
Browse files Browse the repository at this point in the history
introduces:
- lucid list:services
- lucid list:features ([service])
  • Loading branch information
Mulkave committed Jun 25, 2016
1 parent 29e218d commit 6cec1bf
Show file tree
Hide file tree
Showing 9 changed files with 387 additions and 8 deletions.
5 changes: 3 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
- [ ] Change namespace using CLI
- > By extending `Illuminate\Foundation\Console\AppNameCommand`
- [ ] Listing
- [ ] Services
- [ ] Features (per service, and across all services)
- [x] Services
- [x] Features (per service, and across all services)
- [ ] Jobs per feature
- [ ] Domains
- [ ] Pretty Interface
58 changes: 58 additions & 0 deletions src/Commands/FeaturesListCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
* This file is part of the lucid-console project.
*
* (c) Vinelab <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Lucid\Console\Commands;

use Lucid\Console\Finder;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputArgument;

/**
* @author Abed Halawi <[email protected]>
*/
class FeaturesListCommand extends Command
{
use Finder;

/**
* The console command name.
*
* @var string
*/
protected $name = 'list:features';

/**
* The console command description.
*
* @var string
*/
protected $description = 'List the services in this project.';

public function fire()
{
foreach ($this->listFeatures($this->argument('service')) as $service => $features) {
$this->comment("\n$service\n");
$this->table(['Feature', 'Service', 'File', 'Path'], $features);
}
}

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return [
['service', InputArgument::OPTIONAL, 'The service to list the features of.'],
];
}
}
42 changes: 42 additions & 0 deletions src/Commands/ServicesListCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/*
* This file is part of the lucid-console project.
*
* (c) Vinelab <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Lucid\Console\Commands;

use Lucid\Console\Finder;
use Illuminate\Console\Command;

/**
* @author Abed Halawi <[email protected]>
*/
class ServicesListCommand extends Command
{
use Finder;

/**
* The console command name.
*
* @var string
*/
protected $name = 'list:services';

/**
* The console command description.
*
* @var string
*/
protected $description = 'List the services in this project.';

public function fire()
{
$this->table(['Service', 'Slug', 'Path'], $this->listServices());
}
}
54 changes: 54 additions & 0 deletions src/Components/Component.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/*
* This file is part of the lucid-console project.
*
* (c) Vinelab <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Lucid\Console\Components;

use Illuminate\Contracts\Support\Arrayable;

class Component implements Arrayable
{
protected $attributes = [];

/**
* Get the array representation of this instance.
*
* @return array
*/
public function toArray()
{
return $this->attributes;
}

/**
* Set the attributes for this component.
*
* @param array $attributes
*/
protected function setAttributes(array $attributes)
{
$this->attributes = $attributes;
}

/**
* Get an attribute's value if found.
*
* @param string $key
*
* @return mixed
*/
public function __get($key)
{
if (isset($this->attributes[$key])) {
return $this->attributes[$key];
}
}

}
42 changes: 42 additions & 0 deletions src/Components/Feature.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/*
* This file is part of the lucid-console project.
*
* (c) Vinelab <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Lucid\Console\Components;

/**
* @author Abed Halawi <[email protected]>
*/
class Feature extends Component
{
public function __construct($title, $file, $realPath, $relativePath, Service $service)
{
$this->setAttributes([
'title' => $title,
'service' => $service,
'file' => $file,
'realPath' => $realPath,
'relativePath' => $relativePath,
]);
}

public function toArray()
{
$attributes = parent::toArray();

// real path not needed
unset($attributes['realPath']);

// map the service object to its name
$attributes['service'] = $attributes['service']->name;

return $attributes;
}
}
37 changes: 37 additions & 0 deletions src/Components/Service.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
* This file is part of the lucid-console project.
*
* (c) Vinelab <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Lucid\Console\Components;

/**
* @author Abed Halawi <[email protected]>
*/
class Service extends Component
{
public function __construct($name, $realPath, $relativePath)
{
$this->setAttributes([
'name' => $name,
'slug' => snake_case($name),
'realPath' => $realPath,
'relativePath' => $relativePath,
]);
}

public function toArray()
{
$attributes = parent::toArray();

unset($attributes['realPath']);

return $attributes;
}
}
Loading

0 comments on commit 6cec1bf

Please sign in to comment.