Use DICE for Console

- Use Friendica\Core\Console as Controller for DI-library
- Refactor every console command to use DICE (when possible)
- Adjusting tests
This commit is contained in:
Philipp Holzer 2019-07-28 22:06:33 +02:00
parent b8a336cc0d
commit a60eb9e33d
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
20 changed files with 400 additions and 166 deletions

View file

@ -2,7 +2,7 @@
namespace Friendica\Console;
use Friendica\BaseObject;
use Friendica\Core\Config\Configuration;
/**
* Tired of chasing typos and finding them after a commit.
@ -14,6 +14,11 @@ class Typo extends \Asika\SimpleConsole\Console
{
protected $helpOptions = ['h', 'help', '?'];
/**
* @var Configuration
*/
private $config;
protected function getHelp()
{
$help = <<<HELP
@ -31,6 +36,13 @@ HELP;
return $help;
}
public function __construct(Configuration $config, array $argv = null)
{
parent::__construct($argv);
$this->config = $config;
}
protected function doExecute()
{
if ($this->getOption('v')) {
@ -43,7 +55,7 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
$php_path = BaseObject::getApp()->getConfig()->get('config', 'php_path', 'php');
$php_path = $this->config->get('config', 'php_path', 'php');
if ($this->getOption('v')) {
$this->out('Directory: src');