mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
make指令更改为make:file
This commit is contained in:
@@ -49,8 +49,8 @@ class Console
|
|||||||
"think\\console\\command\\Help",
|
"think\\console\\command\\Help",
|
||||||
"think\\console\\command\\Lists",
|
"think\\console\\command\\Lists",
|
||||||
"think\\console\\command\\Build",
|
"think\\console\\command\\Build",
|
||||||
"think\\console\\command\\Make",
|
|
||||||
"think\\console\\command\\make\\Controller",
|
"think\\console\\command\\make\\Controller",
|
||||||
|
"think\\console\\command\\make\\File",
|
||||||
"think\\console\\command\\make\\Model",
|
"think\\console\\command\\make\\Model",
|
||||||
"think\\console\\command\\optimize\\Autoload",
|
"think\\console\\command\\optimize\\Autoload",
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -12,46 +12,16 @@
|
|||||||
namespace think\console\command;
|
namespace think\console\command;
|
||||||
|
|
||||||
use think\App;
|
use think\App;
|
||||||
use think\console\Input;
|
use think\Exception;
|
||||||
use think\console\input\Argument;
|
|
||||||
use think\console\input\Option;
|
|
||||||
use think\console\Output;
|
|
||||||
|
|
||||||
class Make extends Command
|
class Make extends Command
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
$this
|
|
||||||
->setName('make')
|
|
||||||
->setDescription('Create a new applcation class')
|
|
||||||
->addArgument('namespace', Argument::REQUIRED)
|
|
||||||
->addOption('layer', 'l', Option::VALUE_OPTIONAL, 'Layer Name', null)
|
|
||||||
->addOption('extend', 'e', Option::VALUE_OPTIONAL, 'Extend Base class', null);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(Input $input, Output $output)
|
|
||||||
{
|
|
||||||
$namespace = $input->getArgument('namespace');
|
|
||||||
$extend = $input->getOption('extend');
|
|
||||||
if (!$layer = $input->getOption('layer')) {
|
|
||||||
// 自动识别layer
|
|
||||||
$item = explode('\\', $namespace);
|
|
||||||
$layer = basename(dirname(implode(DS, $item)));
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $this->getResult($layer, $namespace, '', $extend);
|
|
||||||
$output->writeln("output:" . $result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建文件
|
// 创建文件
|
||||||
protected static function buildFile($file, $content)
|
protected static function buildFile($file, $content)
|
||||||
{
|
{
|
||||||
if (is_file($file)) {
|
if (is_file($file)) {
|
||||||
exception('file already exists');
|
throw new Exception('file already exists');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_dir(dirname($file))) {
|
if (!is_dir(dirname($file))) {
|
||||||
|
|||||||
48
library/think/console/command/make/File.php
Normal file
48
library/think/console/command/make/File.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2016 http://thinkphp.cn All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: 刘志淳 <chun@engineer.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace think\console\command\make;
|
||||||
|
|
||||||
|
use think\console\Input;
|
||||||
|
use think\console\input\Argument;
|
||||||
|
use think\console\input\Option;
|
||||||
|
use think\console\Output;
|
||||||
|
|
||||||
|
class File extends \think\console\command\Make
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->setName('make:file')
|
||||||
|
->setDescription('Create a new applcation class')
|
||||||
|
->addArgument('namespace', Argument::REQUIRED)
|
||||||
|
->addOption('layer', 'l', Option::VALUE_OPTIONAL, 'Layer Name', null)
|
||||||
|
->addOption('extend', 'e', Option::VALUE_OPTIONAL, 'Extend Base class', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(Input $input, Output $output)
|
||||||
|
{
|
||||||
|
$namespace = $input->getArgument('namespace');
|
||||||
|
$extend = $input->getOption('extend');
|
||||||
|
if (!$layer = $input->getOption('layer')) {
|
||||||
|
// 自动识别layer
|
||||||
|
$item = explode('\\', $namespace);
|
||||||
|
$layer = basename(dirname(implode(DS, $item)));
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->getResult($layer, $namespace, '', $extend);
|
||||||
|
$output->writeln("output:" . $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user