You've already forked Php-Template
All checks were successful
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 1m37s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 1m32s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 1m54s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 1m46s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 1m49s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 1m18s
Reviewed-on: #12 Co-authored-by: Ron Rise <ron@siteworxpro.com> Co-committed-by: Ron Rise <ron@siteworxpro.com>
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Siteworxpro\App\Cli\Commands;
|
|
|
|
use Ahc\Cli\Input\Command;
|
|
|
|
class DemoCommand extends Command implements CommandInterface
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct('api:demo', 'A demo command to showcase the CLI functionality.');
|
|
|
|
$this->argument('[name]', 'Your name')
|
|
->option('-g, --greet', 'Include a greeting message');
|
|
}
|
|
|
|
public function execute(): int
|
|
{
|
|
$pb = $this->progress(100);
|
|
|
|
for ($i = 0; $i < 100; $i += 10) {
|
|
usleep(100000); // Simulate work
|
|
$pb->advance(10);
|
|
}
|
|
|
|
$pb->finish();
|
|
|
|
$this->writer()->boldBlue("Demo Command Executed!\n");
|
|
|
|
if ($this->values()['name']) {
|
|
$name = $this->values()['name'];
|
|
$greet = $this->values()['greet'] ?? false;
|
|
} else {
|
|
return 0;
|
|
}
|
|
|
|
if ($greet) {
|
|
$this->writer()->green("Hello, $name! Welcome to the CLI demo.\n");
|
|
} else {
|
|
$this->writer()->yellow("Name provided: {$name}\n");
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|