Skip to content

Commit d4eb162

Browse files
committed
feat: implement job delete
1 parent 9b431a8 commit d4eb162

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

src/Queue/Commands/DeleteJobCommand.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Leaf\Queue\Commands;
44

55
use Aloe\Command;
6+
use Illuminate\Support\Str;
67

78
class DeleteJobCommand extends Command
89
{
@@ -12,13 +13,27 @@ class DeleteJobCommand extends Command
1213

1314
protected function config()
1415
{
15-
$this->setArgument('job', 'required');
16+
$this->setArgument('job', 'required', 'job name');
1617
}
1718

1819
protected function handle()
1920
{
20-
$job = $this->argument('config');
21+
$job = Str::studly(Str::singular($this->argument('job')));
2122

22-
$this->writeln("Deleting job $job");
23+
if (!strpos($job, 'Job')) {
24+
$job .= 'Job';
25+
}
26+
27+
$file = \Aloe\Command\Config::rootpath(AppPaths('jobs') . "/$job.php");
28+
29+
if (!file_exists($file)) {
30+
$this->error("$job doesn't exist");
31+
return 1;
32+
}
33+
34+
unlink($file);
35+
36+
$this->comment("$job deleted successfully");
37+
return 0;
2338
}
2439
}

0 commit comments

Comments
 (0)