zoukankan      html  css  js  c++  java
  • tp定时任务,传参问题

    <?php
    namespace appcommand;

    use thinkconsoleCommand;
    use thinkconsoleInput;
    use thinkconsoleinputArgument;
    use thinkconsoleinputOption;
    use thinkconsoleOutput;
    use thinkRequest;
    use thinkDb;

    class Test extends Command{ //继承thinkconsoleCommand
    /**
    * 重写configure
    * {@inheritdoc}
    */
    protected function configure()
    {

        //设置参数
        $this->addArgument('email', Argument::REQUIRED); //必传参数
        $this->addArgument('mobile', Argument::OPTIONAL);//可选参数


        //选项定义
        $this->addOption('page', 'm', Option::VALUE_REQUIRED, 'test');//选项值必填
        $this->addOption('status', 's', Option::VALUE_OPTIONAL, 'test'); //选项值选填

        $this->setName('test')
        ->setDescription('执行定时!');
    }


    /**
    * 重写execute
    * {@inheritdoc}
    */
    protected function execute(Input $input, Output $output)
    {

      //获取参数值
      $args = $input->getArguments();
      $output->writeln('The args value is:');
      print_r($args);
      $options = $input->getOptions();
      $output->writeln('The options value is:');
      echo $options['page'];

      $output->writeln('执行成功');
    }

    }

  • 相关阅读:
    Leetcode 121. Best Time to Buy and Sell Stock
    Leetcode 120. Triangle
    Leetcode 26. Remove Duplicates from Sorted Array
    Leetcode 767. Reorganize String
    Leetcode 6. ZigZag Conversion
    KMP HDU 1686 Oulipo
    多重背包 HDU 2844 Coins
    Line belt 三分嵌套
    三分板子 zoj 3203
    二分板子 poj 3122 pie
  • 原文地址:https://www.cnblogs.com/setevn/p/9758909.html
Copyright © 2011-2022 走看看