diff --git a/library/think/console/command/Make.php b/library/think/console/command/Make.php index d20d017f..223e3874 100644 --- a/library/think/console/command/Make.php +++ b/library/think/console/command/Make.php @@ -11,6 +11,7 @@ namespace think\console\command; +use think\App; use think\console\Input; use think\console\input\Argument; use think\console\input\Option; @@ -27,7 +28,7 @@ class Make extends Command $this ->setName('make') ->setDescription('Create a new applcation class') - ->addArgument('namespace', Argument::OPTIONAL, null) + ->addArgument('namespace', Argument::REQUIRED) ->addOption('layer', 'l', Option::VALUE_OPTIONAL, 'Layer Name', null) ->addOption('extend', 'e', Option::VALUE_OPTIONAL, 'Extend Base class', null); } @@ -61,7 +62,7 @@ class Make extends Command } // 生成类库文件 - protected function build($namespace, $extend) + protected function build($namespace, $extend, $content = '') { $tpl = file_get_contents(THINK_PATH . 'tpl' . DS . 'make.tpl'); @@ -73,8 +74,8 @@ class Make extends Command $extend = 'extends \\' . ltrim($extend, '\\'); } // 处理内容 - $content = str_replace(['{%extend%}', '{%className%}', '{%namespace%}'], - [$extend, $className, implode('\\', $namespace)], + $content = str_replace(['{%extend%}', '{%className%}', '{%namespace%}', '{%content%}'], + [$extend, $className, implode('\\', $namespace), $content], $tpl); // 处理文件名 @@ -86,7 +87,7 @@ class Make extends Command return realpath($file); } - protected function getResult($layer, $namespace, $module, $extend) + protected function getResult($layer, $namespace, $module, $extend, $content = '') { // 处理命名空间 @@ -116,6 +117,6 @@ class Make extends Command } } - return $this->build($namespace, $extend); + return $this->build($namespace, $extend, $content); } } diff --git a/library/think/console/command/make/Controller.php b/library/think/console/command/make/Controller.php index ac9d8ffb..318fbcd9 100644 --- a/library/think/console/command/make/Controller.php +++ b/library/think/console/command/make/Controller.php @@ -26,7 +26,7 @@ class Controller extends \think\console\command\Make $this ->setName('make:controller') ->setDescription('Create a new controller class') - ->addArgument('namespace', Argument::OPTIONAL, null) + ->addArgument('namespace', Argument::REQUIRED) ->addOption('module', 'm', Option::VALUE_OPTIONAL, 'Module Name', null) ->addOption('extend', 'e', Option::VALUE_OPTIONAL, 'Base on Controller class', null); } diff --git a/library/think/console/command/make/Model.php b/library/think/console/command/make/Model.php index 91a4fa81..e6e9afd1 100644 --- a/library/think/console/command/make/Model.php +++ b/library/think/console/command/make/Model.php @@ -26,7 +26,7 @@ class Model extends \think\console\command\Make $this ->setName('make:model') ->setDescription('Create a new model class') - ->addArgument('namespace', Argument::OPTIONAL, null) + ->addArgument('namespace', Argument::REQUIRED) ->addOption('module', 'm', Option::VALUE_OPTIONAL, 'Module Name', null) ->addOption('extend', 'e', Option::VALUE_OPTIONAL, 'Base on Model class', null); } diff --git a/tpl/make.tpl b/tpl/make.tpl index 6b7ccbcf..fad4123f 100644 --- a/tpl/make.tpl +++ b/tpl/make.tpl @@ -13,5 +13,5 @@ namespace {%namespace%}; class {%className%} {%extend%} { - +{%content%} }