This commit is contained in:
Markus
2022-04-28 09:40:10 +02:00
commit 795794f992
9586 changed files with 1146991 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Support\Commands;
use CodeIgniter\CLI\BaseCommand;
abstract class AbstractInfo extends BaseCommand
{
protected $group = 'demo';
protected $name = 'app:pablo';
protected $description = 'Displays basic application information.';
}

View File

@@ -0,0 +1,44 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Support\Commands;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\CodeIgniter;
use RuntimeException;
class AppInfo extends BaseCommand
{
protected $group = 'demo';
protected $name = 'app:info';
protected $arguments = ['draft' => 'unused'];
protected $description = 'Displays basic application information.';
public function run(array $params)
{
CLI::write('CI Version: ' . CLI::color(CodeIgniter::CI_VERSION, 'red'));
}
public function bomb()
{
try {
CLI::color('test', 'white', 'Background');
} catch (RuntimeException $oops) {
$this->showError($oops);
}
}
public function helpme()
{
$this->call('help');
}
}

View File

@@ -0,0 +1,11 @@
<?php
use Config\App;
use CodeIgniter\CLI\CLI;
return [
'foo' => 'The command will use this as foo.',
'bar' => 'The command will use this as bar.',
'baz' => 'The baz is here.',
'bas' => CLI::color('bas', 'green') . (new App())->baseURL,
];

View File

@@ -0,0 +1,34 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Support\Commands;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\CodeIgniter;
use ReflectionException;
class InvalidCommand extends BaseCommand
{
protected $group = 'demo';
protected $name = 'app:invalid';
protected $description = '';
public function __construct()
{
throw new ReflectionException();
}
public function run(array $params)
{
CLI::write('CI Version: ' . CLI::color(CodeIgniter::CI_VERSION, 'red'));
}
}

View File

@@ -0,0 +1,49 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Support\Commands;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\GeneratorTrait;
class LanguageCommand extends BaseCommand
{
use GeneratorTrait;
protected $group = 'Generators';
protected $name = 'publish:language';
protected $description = 'Publishes a language file.';
protected $usage = 'publish:language [options]';
protected $options = [
'--lang' => 'The language folder to save the file.',
'--sort' => 'Turn on/off the sortImports flag.',
];
public function run(array $params)
{
$this->setHasClassName(false);
$params[0] = 'Foobar';
$params['lang'] = $params['lang'] ?? 'en';
$this->component = 'Language';
$this->directory = 'Language\\' . $params['lang'];
$sort = (isset($params['sort']) && $params['sort'] === 'off') ? false : true;
$this->setSortImports($sort);
$this->execute($params);
}
protected function prepare(string $class): string
{
return file_get_contents(__DIR__ . '/Foobar.php') ?: '';
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Support\Commands;
use CodeIgniter\CLI\BaseCommand;
class ParamsReveal extends BaseCommand
{
protected $group = 'demo';
protected $name = 'reveal';
protected $usage = 'reveal [options] [arguments]';
protected $description = 'Reveal params';
public static $args;
public function run(array $params)
{
static::$args = $params;
}
}

View File

@@ -0,0 +1,77 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Support\Commands;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\GeneratorTrait;
class Unsuffixable extends BaseCommand
{
use GeneratorTrait;
/**
* The Command's Group
*
* @var string
*/
protected $group = 'Generators';
/**
* The Command's Name
*
* @var string
*/
protected $name = 'make:foo';
/**
* The Command's Description
*
* @var string
*/
protected $description = '';
/**
* The Command's Usage
*
* @var string
*/
protected $usage = 'make:foo [arguments] [options]';
/**
* The Command's Arguments
*
* @var array
*/
protected $arguments = [
'name' => 'Class name',
];
/**
* The Command's Options
*
* @var array
*/
protected $options = [];
/**
* Actually execute a command.
*/
public function run(array $params)
{
$this->component = 'Command';
$this->directory = 'Commands';
$this->template = 'command.tpl.php';
$this->setEnabledSuffixing(false);
$this->execute($params);
}
}