think\console\Input::hasArgument PHP Method

hasArgument() public method

检查是否存在某个参数
public hasArgument ( string | integer $name ) : boolean
$name string | integer 参数名或位置
return boolean
    public function hasArgument($name)
    {
        return $this->definition->hasArgument($name);
    }

Usage Example

Esempio n. 1
0
 protected function execute(Input $input, Output $output)
 {
     if ($input->hasArgument('module')) {
         $module = $input->getArgument('module') . DS;
     } else {
         $module = '';
     }
     $content = '<?php ' . PHP_EOL . $this->buildCacheContent($module);
     if (!is_dir(RUNTIME_PATH . $module)) {
         @mkdir(RUNTIME_PATH . $module, 0755, true);
     }
     file_put_contents(RUNTIME_PATH . $module . 'init' . EXT, $content);
     $output->writeln('<info>Succeed!</info>');
 }