Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,34 @@ To do that, put this in your shell profile (~/.bash_profile, ~/.zshrc, ~/bashrc)
- **make**
- `make:controller` Create a new resource Controller class in a service
- `make:feature ` Create a new Feature in a service
- `make:operation ` Create a new Operation in a service
- `make:job ` Create a new Job in a domain
- `make:service ` Create a new Service
- `make:model ` Create a new Model
- `make:request ` Create a new Request in a service
- `make:policy ` Create a new Policy
- **list**
- `list:features` List the features.
- `list:services` List the services in this project.
- **delete**
- `delete:feature` Delete an existing Feature in a service
- `delete:operation` Delete an existing Operation in a service
- `delete:job ` Delete an existing Job in a domain
- `delete:service` Delete an existing Service
- `delete:model ` Delete an existing Model
- `delete:request ` Delete an existing Request in a service
- `delete:policy ` Delete an existing Policy

### Commands Usage

#### Make
- `make:controller <controller> [<service>]`
- `make:feature <feature> [<service>]`
- `make:job <job> <domain>`
- `make:job <job> <domain> [--queue]`
- `make:service <name>`
- `make:model <model>`
- `make:request <request> [<service>]`
- `make:policy <policy>`

#### List
- `list:services`
Expand All @@ -43,3 +54,6 @@ To do that, put this in your shell profile (~/.bash_profile, ~/.zshrc, ~/bashrc)
- `delete:service <name>`
- `delete:feature <feature> [<service>]`
- `delete:job <job> <domain>`
- `delete:model <model>`
- `delete:request <request> [<service>]`
- `delete:policy <policy>`
15 changes: 15 additions & 0 deletions config/lucid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Dashboard
|--------------------------------------------------------------------------
|
| By default /lucid/dashboard is available when env('APP_DEBUG') is true.
| If you set this value to "true" it will be always accessible even on
| production environment.
|
*/
'dashboard' => null,
];
10 changes: 10 additions & 0 deletions lucid
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ $commands = [
new Lucid\Console\Commands\ControllerMakeCommand(),
new Lucid\Console\Commands\ServicesListCommand(),
new Lucid\Console\Commands\FeaturesListCommand(),

new \Lucid\Console\Commands\ModelMakeCommand(),
new \Lucid\Console\Commands\ModelDeleteCommand(),
new \Lucid\Console\Commands\RequestMakeCommand(),
new \Lucid\Console\Commands\RequestDeleteCommand(),
new \Lucid\Console\Commands\PolicyMakeCommand(),
new \Lucid\Console\Commands\PolicyDeleteCommand(),

new \Lucid\Console\Commands\OperationMakeCommand(),
new \Lucid\Console\Commands\OperationDeleteCommand(),
];

$app = new Symfony\Component\Console\Application('Lucid Console', '0.5.0');
Expand Down
20 changes: 14 additions & 6 deletions src/Commands/JobMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@

namespace Lucid\Console\Commands;

use Lucid\Console\Str;
use Lucid\Console\Finder;
use Lucid\Console\Command;
use Lucid\Console\Filesystem;
use Lucid\Console\Finder;
use Lucid\Console\Generators\JobGenerator;
use Symfony\Component\Console\Input\InputArgument;
use Lucid\Console\Str;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

/**
* @author Abed Halawi <abed.halawi@vinelab.com>
Expand All @@ -33,7 +34,7 @@ class JobMakeCommand extends SymfonyCommand
*
* @var string
*/
protected $name = 'make:job';
protected $name = 'make:job {--Q|queue}';

/**
* The console command description.
Expand All @@ -60,9 +61,9 @@ public function fire()

$domain = studly_case($this->argument('domain'));
$title = $this->parseName($this->argument('job'));

$isQueueable = $this->option('queue');
try {
$job = $generator->generate($title, $domain);
$job = $generator->generate($title, $domain, $isQueueable);

$this->info(
'Job class '.$title.' created successfully.'.
Expand All @@ -83,6 +84,13 @@ public function getArguments()
];
}

public function getOptions()
{
return [
['queue', 'Q', InputOption::VALUE_NONE, 'Whether a job is queueable or not.'],
];
}

/**
* Get the stub file for the generator.
*
Expand Down
101 changes: 101 additions & 0 deletions src/Commands/ModelDeleteCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php

namespace Lucid\Console\Commands;

use Exception;
use Lucid\Console\Str;
use Lucid\Console\Command;
use Lucid\Console\Filesystem;
use Lucid\Console\Finder;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
use Symfony\Component\Console\Input\InputArgument;


/**
* Class ModelDeleteCommand
*
* @author Bernat Jufré <info@behind.design>
*
* @package Lucid\Console\Commands
*/
class ModelDeleteCommand extends SymfonyCommand
{
use Finder;
use Command;
use Filesystem;

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

/**
* The console command description.
*
* @var string
*/
protected $description = 'Delete an existing Eloquent Model.';

/**
* The type of class being generated
* @var string
*/
protected $type = 'Model';

/**
* Execute the console command.
*
* @return bool|null
*/
public function fire()
{
try {
$model = $this->parseModelName($this->argument('model'));

if ( ! $this->exists($path = $this->findModelPath($model))) {
$this->error('Model class ' . $model . ' cannot be found.');
} else {
$this->delete($path);

$this->info('Model class <comment>' . $model . '</comment> deleted successfully.');
}
} catch (Exception $e) {
$this->error($e->getMessage());
}
}

/**
* Get the console command arguments.
*
* @return array
*/
public function getArguments()
{
return [
['model', InputArgument::REQUIRED, 'The Model\'s name.']
];
}

/**
* Get the stub file for the generator.
*
* @return string
*/
public function getStub()
{
return __DIR__ . '/../Generators/stubs/model.stub';
}

/**
* Parse the model name.
*
* @param string $name
* @return string
*/
public function parseModelName($name)
{
return Str::model($name);
}
}
92 changes: 92 additions & 0 deletions src/Commands/ModelMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

namespace Lucid\Console\Commands;

use Exception;
use Lucid\Console\Generators\ModelGenerator;
use Lucid\Console\Command;
use Lucid\Console\Filesystem;
use Lucid\Console\Finder;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
use Symfony\Component\Console\Input\InputArgument;


/**
* Class ModelMakeCommand
*
* @author Bernat Jufré <info@behind.design>
*
* @package Lucid\Console\Commands
*/
class ModelMakeCommand extends SymfonyCommand
{
use Finder;
use Command;
use Filesystem;

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

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new Eloquent Model.';

/**
* The type of class being generated
* @var string
*/
protected $type = 'Model';

/**
* Execute the console command.
*
* @return bool|null
*/
public function fire()
{
$generator = new ModelGenerator();

$name = $this->argument('model');

try {
$model = $generator->generate($name);

$this->info('Model class created successfully.' .
"\n" .
"\n" .
'Find it at <comment>' . $model->relativePath . '</comment>' . "\n"
);
} catch (Exception $e) {
$this->error($e->getMessage());
}
}

/**
* Get the console command arguments.
*
* @return array
*/
public function getArguments()
{
return [
['model', InputArgument::REQUIRED, 'The Model\'s name.']
];
}

/**
* Get the stub file for the generator.
*
* @return string
*/
public function getStub()
{
return __DIR__ . '/../Generators/stubs/model.stub';
}
}
Loading