76 lines
No EOL
1.1 KiB
PHP
76 lines
No EOL
1.1 KiB
PHP
<?php
|
|
|
|
namespace Cli\Commands;
|
|
|
|
use Cli\Assets\Console;
|
|
|
|
class Command
|
|
{
|
|
use Console;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
public $signature = '';
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
public $description = '';
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
private $args = [];
|
|
|
|
/**
|
|
* Command constructor.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->args = $this->getArgs();
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
private function getArgs()
|
|
{
|
|
global $argv;
|
|
|
|
$args = [];
|
|
for ($i = 1; $i < count($argv); $i++) {
|
|
if (preg_match('/^--([^=]+)=(.*)/', $argv[$i], $match)) {
|
|
$args[$match[1]] = $match[2];
|
|
}
|
|
}
|
|
|
|
return $args;
|
|
}
|
|
|
|
/**
|
|
* @param $name
|
|
* @return string
|
|
*/
|
|
public function argument($name)
|
|
{
|
|
return $this->args[$name];
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->signature;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getDescription()
|
|
{
|
|
return $this->description;
|
|
}
|
|
|
|
} |