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

Commit c2dd941

Browse files
authored
Merge pull request #9 from lucid-architecture/master
Merge console-laravel master branch
2 parents e762c41 + b503274 commit c2dd941

33 files changed

+1702
-16
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,34 @@ To do that, put this in your shell profile (~/.bash_profile, ~/.zshrc, ~/bashrc)
1717
- **make**
1818
- `make:controller` Create a new resource Controller class in a service
1919
- `make:feature ` Create a new Feature in a service
20+
- `make:operation ` Create a new Operation in a service
2021
- `make:job ` Create a new Job in a domain
2122
- `make:service ` Create a new Service
23+
- `make:model ` Create a new Model
24+
- `make:request ` Create a new Request in a service
25+
- `make:policy ` Create a new Policy
2226
- **list**
2327
- `list:features` List the features.
2428
- `list:services` List the services in this project.
2529
- **delete**
2630
- `delete:feature` Delete an existing Feature in a service
31+
- `delete:operation` Delete an existing Operation in a service
2732
- `delete:job ` Delete an existing Job in a domain
2833
- `delete:service` Delete an existing Service
34+
- `delete:model ` Delete an existing Model
35+
- `delete:request ` Delete an existing Request in a service
36+
- `delete:policy ` Delete an existing Policy
2937

3038
### Commands Usage
3139

3240
#### Make
3341
- `make:controller <controller> [<service>]`
3442
- `make:feature <feature> [<service>]`
35-
- `make:job <job> <domain>`
43+
- `make:job <job> <domain> [--queue]`
3644
- `make:service <name>`
45+
- `make:model <model>`
46+
- `make:request <request> [<service>]`
47+
- `make:policy <policy>`
3748

3849
#### List
3950
- `list:services`
@@ -43,3 +54,6 @@ To do that, put this in your shell profile (~/.bash_profile, ~/.zshrc, ~/bashrc)
4354
- `delete:service <name>`
4455
- `delete:feature <feature> [<service>]`
4556
- `delete:job <job> <domain>`
57+
- `delete:model <model>`
58+
- `delete:request <request> [<service>]`
59+
- `delete:policy <policy>`

config/lucid.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Dashboard
7+
|--------------------------------------------------------------------------
8+
|
9+
| By default /lucid/dashboard is available when env('APP_DEBUG') is true.
10+
| If you set this value to "true" it will be always accessible even on
11+
| production environment.
12+
|
13+
*/
14+
'dashboard' => null,
15+
];

lucid

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ $commands = [
1919
new Lucid\Console\Commands\ControllerMakeCommand(),
2020
new Lucid\Console\Commands\ServicesListCommand(),
2121
new Lucid\Console\Commands\FeaturesListCommand(),
22+
23+
new \Lucid\Console\Commands\ModelMakeCommand(),
24+
new \Lucid\Console\Commands\ModelDeleteCommand(),
25+
new \Lucid\Console\Commands\RequestMakeCommand(),
26+
new \Lucid\Console\Commands\RequestDeleteCommand(),
27+
new \Lucid\Console\Commands\PolicyMakeCommand(),
28+
new \Lucid\Console\Commands\PolicyDeleteCommand(),
29+
30+
new \Lucid\Console\Commands\OperationMakeCommand(),
31+
new \Lucid\Console\Commands\OperationDeleteCommand(),
2232
];
2333

2434
$app = new Symfony\Component\Console\Application('Lucid Console', '0.5.0');

src/Commands/JobMakeCommand.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111

1212
namespace Lucid\Console\Commands;
1313

14-
use Lucid\Console\Str;
15-
use Lucid\Console\Finder;
1614
use Lucid\Console\Command;
1715
use Lucid\Console\Filesystem;
16+
use Lucid\Console\Finder;
1817
use Lucid\Console\Generators\JobGenerator;
19-
use Symfony\Component\Console\Input\InputArgument;
18+
use Lucid\Console\Str;
2019
use Symfony\Component\Console\Command\Command as SymfonyCommand;
20+
use Symfony\Component\Console\Input\InputArgument;
21+
use Symfony\Component\Console\Input\InputOption;
2122

2223
/**
2324
* @author Abed Halawi <[email protected]>
@@ -33,7 +34,7 @@ class JobMakeCommand extends SymfonyCommand
3334
*
3435
* @var string
3536
*/
36-
protected $name = 'make:job';
37+
protected $name = 'make:job {--Q|queue}';
3738

3839
/**
3940
* The console command description.
@@ -60,9 +61,9 @@ public function fire()
6061

6162
$domain = studly_case($this->argument('domain'));
6263
$title = $this->parseName($this->argument('job'));
63-
64+
$isQueueable = $this->option('queue');
6465
try {
65-
$job = $generator->generate($title, $domain);
66+
$job = $generator->generate($title, $domain, $isQueueable);
6667

6768
$this->info(
6869
'Job class '.$title.' created successfully.'.
@@ -83,6 +84,13 @@ public function getArguments()
8384
];
8485
}
8586

87+
public function getOptions()
88+
{
89+
return [
90+
['queue', 'Q', InputOption::VALUE_NONE, 'Whether a job is queueable or not.'],
91+
];
92+
}
93+
8694
/**
8795
* Get the stub file for the generator.
8896
*

src/Commands/ModelDeleteCommand.php

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
3+
namespace Lucid\Console\Commands;
4+
5+
use Exception;
6+
use Lucid\Console\Str;
7+
use Lucid\Console\Command;
8+
use Lucid\Console\Filesystem;
9+
use Lucid\Console\Finder;
10+
use Symfony\Component\Console\Command\Command as SymfonyCommand;
11+
use Symfony\Component\Console\Input\InputArgument;
12+
13+
14+
/**
15+
* Class ModelDeleteCommand
16+
*
17+
* @author Bernat Jufré <[email protected]>
18+
*
19+
* @package Lucid\Console\Commands
20+
*/
21+
class ModelDeleteCommand extends SymfonyCommand
22+
{
23+
use Finder;
24+
use Command;
25+
use Filesystem;
26+
27+
/**
28+
* The console command name.
29+
*
30+
* @var string
31+
*/
32+
protected $name = 'delete:model';
33+
34+
/**
35+
* The console command description.
36+
*
37+
* @var string
38+
*/
39+
protected $description = 'Delete an existing Eloquent Model.';
40+
41+
/**
42+
* The type of class being generated
43+
* @var string
44+
*/
45+
protected $type = 'Model';
46+
47+
/**
48+
* Execute the console command.
49+
*
50+
* @return bool|null
51+
*/
52+
public function fire()
53+
{
54+
try {
55+
$model = $this->parseModelName($this->argument('model'));
56+
57+
if ( ! $this->exists($path = $this->findModelPath($model))) {
58+
$this->error('Model class ' . $model . ' cannot be found.');
59+
} else {
60+
$this->delete($path);
61+
62+
$this->info('Model class <comment>' . $model . '</comment> deleted successfully.');
63+
}
64+
} catch (Exception $e) {
65+
$this->error($e->getMessage());
66+
}
67+
}
68+
69+
/**
70+
* Get the console command arguments.
71+
*
72+
* @return array
73+
*/
74+
public function getArguments()
75+
{
76+
return [
77+
['model', InputArgument::REQUIRED, 'The Model\'s name.']
78+
];
79+
}
80+
81+
/**
82+
* Get the stub file for the generator.
83+
*
84+
* @return string
85+
*/
86+
public function getStub()
87+
{
88+
return __DIR__ . '/../Generators/stubs/model.stub';
89+
}
90+
91+
/**
92+
* Parse the model name.
93+
*
94+
* @param string $name
95+
* @return string
96+
*/
97+
public function parseModelName($name)
98+
{
99+
return Str::model($name);
100+
}
101+
}

src/Commands/ModelMakeCommand.php

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
namespace Lucid\Console\Commands;
4+
5+
use Exception;
6+
use Lucid\Console\Generators\ModelGenerator;
7+
use Lucid\Console\Command;
8+
use Lucid\Console\Filesystem;
9+
use Lucid\Console\Finder;
10+
use Symfony\Component\Console\Command\Command as SymfonyCommand;
11+
use Symfony\Component\Console\Input\InputArgument;
12+
13+
14+
/**
15+
* Class ModelMakeCommand
16+
*
17+
* @author Bernat Jufré <[email protected]>
18+
*
19+
* @package Lucid\Console\Commands
20+
*/
21+
class ModelMakeCommand extends SymfonyCommand
22+
{
23+
use Finder;
24+
use Command;
25+
use Filesystem;
26+
27+
/**
28+
* The console command name.
29+
*
30+
* @var string
31+
*/
32+
protected $name = 'make:model';
33+
34+
/**
35+
* The console command description.
36+
*
37+
* @var string
38+
*/
39+
protected $description = 'Create a new Eloquent Model.';
40+
41+
/**
42+
* The type of class being generated
43+
* @var string
44+
*/
45+
protected $type = 'Model';
46+
47+
/**
48+
* Execute the console command.
49+
*
50+
* @return bool|null
51+
*/
52+
public function fire()
53+
{
54+
$generator = new ModelGenerator();
55+
56+
$name = $this->argument('model');
57+
58+
try {
59+
$model = $generator->generate($name);
60+
61+
$this->info('Model class created successfully.' .
62+
"\n" .
63+
"\n" .
64+
'Find it at <comment>' . $model->relativePath . '</comment>' . "\n"
65+
);
66+
} catch (Exception $e) {
67+
$this->error($e->getMessage());
68+
}
69+
}
70+
71+
/**
72+
* Get the console command arguments.
73+
*
74+
* @return array
75+
*/
76+
public function getArguments()
77+
{
78+
return [
79+
['model', InputArgument::REQUIRED, 'The Model\'s name.']
80+
];
81+
}
82+
83+
/**
84+
* Get the stub file for the generator.
85+
*
86+
* @return string
87+
*/
88+
public function getStub()
89+
{
90+
return __DIR__ . '/../Generators/stubs/model.stub';
91+
}
92+
}

0 commit comments

Comments
 (0)