Skip to content

Commit 9673802

Browse files
authored
Merge pull request #1 from dotkernel/fix/minor-fixes
Minor improvements
2 parents e2e4c8a + 7bbeec0 commit 9673802

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,21 @@ Options:
5252
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
5353
5454
Available commands:
55-
demo-command Demo command description.
5655
help Display help for a command
5756
list List commands
57+
demo
58+
demo:command Demo command description.
5859
```
59-
As shown in `config/autoload/cli.global.php`, dot-cli includes a demo command `demo-command` that will help you understand the basics of creating a new command.
60+
As shown in `config/autoload/cli.global.php`, dot-cli includes a demo command `demo:command` that will help you understand the basics of creating a new command.
6061
For more information, see [laminas-cli documentation](https://docs.laminas.dev/laminas-cli/).
6162

6263
### Setting up as cronjob
6364
```text
64-
* * * * * /opt/plesk/php/7.4/bin/php /var/www/vhosts/example.com/httpdocs/bin/cli.php demo-command -q
65+
* * * * * /opt/plesk/php/7.4/bin/php /var/www/vhosts/example.com/httpdocs/bin/cli.php demo:command -q
6566
```
6667
or
6768
```text
68-
* * * * * cd /var/www/vhosts/example.com/httpdocs/bin && /opt/plesk/php/7.4/bin/php ./cli.php demo-command -q
69+
* * * * * cd /var/www/vhosts/example.com/httpdocs/bin && /opt/plesk/php/7.4/bin/php ./cli.php demo:command -q
6970
```
7071
Adapt the command to your specifications by replacing **7.4** with your PHP version and **example.com** with your domain name.
7172

config/autoload/cli.global.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
'dot_cli' => [
1111
'version' => '1.0.0',
1212
'name' => 'DotKernel CLI',
13-
'showVersion' => true,
1413
'commands' => [
15-
'demo-command' => DemoCommand::class,
14+
DemoCommand::getDefaultName() => DemoCommand::class,
1615
]
1716
],
1817
FileLockerInterface::class => [

src/Application.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public function __destruct()
4545
*/
4646
public function doRun(InputInterface $input, OutputInterface $output): int
4747
{
48-
$commandName = $this->getCommandName($input);
49-
$this->fileLocker->setCommandName($commandName)->setEnabled(true);
48+
$this->fileLocker->setCommandName($this->getCommandName($input));
5049

5150
try {
5251
$this->fileLocker->lock();

src/Command/DemoCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
class DemoCommand extends Command
1818
{
19-
protected static $defaultName = 'demo-command';
19+
protected static $defaultName = 'demo:command';
2020

2121
/**
2222
* @return void

src/FileLocker.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ public function setCommandName(?string $commandName): self
9090
*/
9191
public function getLockFilePath(): string
9292
{
93-
return sprintf('%s/command-%s.lock', $this->dirPath, $this->commandName);
93+
$commandName = str_replace(':', '-', $this->commandName);
94+
return sprintf('%s/command-%s.lock', $this->dirPath, $commandName);
9495
}
9596

9697
/**

0 commit comments

Comments
 (0)