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

Commit 48c1f8a

Browse files
committed
Merge branch 'master' into dev
2 parents 088f792 + e77940e commit 48c1f8a

File tree

6 files changed

+345
-7
lines changed

6 files changed

+345
-7
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"symfony/console": "^2.7|^3.0",
2121
"symfony/process": "^2.7|^3.0",
2222
"symfony/finder": "^2.7|^3.0",
23+
"symfony/filesystem": "^2.7|^3.0",
2324
"stevebauman/log-reader": "^1.1",
2425
"phploc/phploc": "^3.0"
2526
}

lucid

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ $laravel = require __DIR__.'/../../../bootstrap/app.php';
1111

1212
$commands = [
1313
new Lucid\Console\Commands\JobMakeCommand(),
14+
new Lucid\Console\Commands\JobDeleteCommand(),
1415
new Lucid\Console\Commands\ServiceMakeCommand(),
16+
new Lucid\Console\Commands\ServiceDeleteCommand(),
1517
new Lucid\Console\Commands\FeatureMakeCommand(),
18+
new Lucid\Console\Commands\FeatureDeleteCommand(),
1619
new Lucid\Console\Commands\ControllerMakeCommand(),
1720
new Lucid\Console\Commands\ServicesListCommand(),
1821
new Lucid\Console\Commands\FeaturesListCommand(),

src/Commands/FeatureDeleteCommand.php

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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\Str;
15+
use Lucid\Console\Finder;
16+
use Lucid\Console\Command;
17+
use Lucid\Console\Filesystem;
18+
use Symfony\Component\Console\Input\InputArgument;
19+
use Symfony\Component\Console\Command\Command as SymfonyCommand;
20+
21+
/**
22+
* @author Charalampos Raftopoulos <[email protected]>
23+
*/
24+
class FeatureDeleteCommand extends SymfonyCommand
25+
{
26+
use Finder;
27+
use Command;
28+
use Filesystem;
29+
30+
/**
31+
* The console command name.
32+
*
33+
* @var string
34+
*/
35+
protected $name = 'delete:feature';
36+
37+
/**
38+
* The console command description.
39+
*
40+
* @var string
41+
*/
42+
protected $description = 'Delete an existing Feature in a service';
43+
44+
/**
45+
* The type of class being deleted.
46+
*
47+
* @var string
48+
*/
49+
protected $type = 'Feature';
50+
51+
/**
52+
* Execute the console command.
53+
*
54+
* @return bool|null
55+
*/
56+
public function fire()
57+
{
58+
try {
59+
$service = studly_case($this->argument('service'));
60+
$title = $this->parseName($this->argument('feature'));
61+
62+
if (!$this->exists($feature = $this->findFeaturePath($service, $title))) {
63+
$this->error('Feature class '.$title.' cannot be found.');
64+
} else {
65+
$this->delete($feature);
66+
67+
$this->info('Feature class <comment>'.$title.'</comment> deleted successfully.');
68+
}
69+
} catch (Exception $e) {
70+
$this->error($e->getMessage());
71+
}
72+
}
73+
74+
/**
75+
* Get the console command arguments.
76+
*
77+
* @return array
78+
*/
79+
protected function getArguments()
80+
{
81+
return [
82+
['service', InputArgument::REQUIRED, 'The service in which the feature should be deleted from.'],
83+
['feature', InputArgument::REQUIRED, 'The feature\'s name.'],
84+
];
85+
}
86+
87+
/**
88+
* Get the stub file for the generator.
89+
*
90+
* @return string
91+
*/
92+
protected function getStub()
93+
{
94+
return __DIR__.'/../Generators/stubs/feature.stub';
95+
}
96+
97+
/**
98+
* Parse the feature name.
99+
* remove the Feature.php suffix if found
100+
* we're adding it ourselves.
101+
*
102+
* @param string $name
103+
*
104+
* @return string
105+
*/
106+
protected function parseName($name)
107+
{
108+
return Str::feature($name);
109+
}
110+
}

src/Commands/JobDeleteCommand.php

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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\Str;
15+
use Lucid\Console\Finder;
16+
use Lucid\Console\Command;
17+
use Lucid\Console\Filesystem;
18+
use Symfony\Component\Console\Input\InputArgument;
19+
use Symfony\Component\Console\Command\Command as SymfonyCommand;
20+
21+
/**
22+
* @author Charalampos Raftopoulos <[email protected]>
23+
*/
24+
class JobDeleteCommand extends SymfonyCommand
25+
{
26+
use Finder;
27+
use Command;
28+
use Filesystem;
29+
30+
/**
31+
* The console command name.
32+
*
33+
* @var string
34+
*/
35+
protected $name = 'delete:job';
36+
37+
/**
38+
* The console command description.
39+
*
40+
* @var string
41+
*/
42+
protected $description = 'Delete an existing Job in a domain';
43+
44+
/**
45+
* The type of class being deleted.
46+
*
47+
* @var string
48+
*/
49+
protected $type = 'Job';
50+
51+
/**
52+
* Execute the console command.
53+
*
54+
* @return bool|null
55+
*/
56+
public function fire()
57+
{
58+
try {
59+
$domain = studly_case($this->argument('domain'));
60+
$title = $this->parseName($this->argument('job'));
61+
62+
if (!$this->exists($job = $this->findJobPath($domain, $title))) {
63+
$this->error('Job class '.$title.' cannot be found.');
64+
} else {
65+
$this->delete($job);
66+
67+
if (count($this->listJobs($domain)->first()) === 0) {
68+
$this->delete($this->findDomainPath($domain));
69+
}
70+
71+
$this->info('Job class <comment>'.$title.'</comment> deleted successfully.');
72+
}
73+
} catch (Exception $e) {
74+
$this->error($e->getMessage());
75+
}
76+
}
77+
78+
public function getArguments()
79+
{
80+
return [
81+
['domain', InputArgument::REQUIRED, 'The domain from which the job will be deleted.'],
82+
['job', InputArgument::REQUIRED, 'The job\'s name.'],
83+
];
84+
}
85+
86+
/**
87+
* Get the stub file for the generator.
88+
*
89+
* @return string
90+
*/
91+
public function getStub()
92+
{
93+
return __DIR__.'/../Generators/stubs/job.stub';
94+
}
95+
96+
/**
97+
* Parse the job name.
98+
* remove the Job.php suffix if found
99+
* we're adding it ourselves.
100+
*
101+
* @param string $name
102+
*
103+
* @return string
104+
*/
105+
protected function parseName($name)
106+
{
107+
return Str::job($name);
108+
}
109+
}

src/Commands/ServiceDeleteCommand.php

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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 Lucid\Console\Command;
16+
use Lucid\Console\Filesystem;
17+
use Symfony\Component\Console\Input\InputArgument;
18+
use Symfony\Component\Console\Command\Command as SymfonyCommand;
19+
20+
/**
21+
* @author Charalampos Raftopoulos <[email protected]>
22+
*/
23+
class ServiceDeleteCommand extends SymfonyCommand
24+
{
25+
use Finder;
26+
use Command;
27+
use Filesystem;
28+
29+
/**
30+
* The base namespace for this command.
31+
*
32+
* @var string
33+
*/
34+
private $namespace;
35+
36+
/**
37+
* The Services path.
38+
*
39+
* @var string
40+
*/
41+
private $path;
42+
43+
/**
44+
* The console command name.
45+
*
46+
* @var string
47+
*/
48+
protected $name = 'delete:service';
49+
50+
/**
51+
* The console command description.
52+
*
53+
* @var string
54+
*/
55+
protected $description = 'Delete an existing Service';
56+
57+
/**
58+
* Get the stub file for the generator.
59+
*
60+
* @return string
61+
*/
62+
protected function getStub()
63+
{
64+
return __DIR__.'/../Generators/stubs/service.stub';
65+
}
66+
67+
/**
68+
* Execute the console command.
69+
*
70+
* @return bool|null
71+
*/
72+
public function fire()
73+
{
74+
try {
75+
$name = ucfirst($this->argument('name'));
76+
77+
if (!$this->exists($service = $this->findServicePath($name))) {
78+
$this->error('Service '.$name.' cannot be found.');
79+
} else {
80+
$this->delete($service);
81+
82+
$this->info('Service <comment>'.$name.'</comment> deleted successfully.'."\n");
83+
84+
$this->info('Please remove your registered service providers, if any.');
85+
}
86+
} catch (\Exception $e) {
87+
dd($e->getMessage(), $e->getFile(), $e->getLine());
88+
}
89+
}
90+
91+
public function getArguments()
92+
{
93+
return [
94+
['name', InputArgument::REQUIRED, 'The service name.'],
95+
];
96+
}
97+
}

0 commit comments

Comments
 (0)