<?php declare (strict_types=1); namespace app\command; use app\common\repositories\system\admin\AdminRepository; use think\console\Command; use think\console\Input; use think\console\input\Argument; use think\console\Output; use think\console\input\Option; class resetPassword extends Command { protected function configure() { // 指令配置 $this->setName('reset:password') ->addArgument('root', Argument::OPTIONAL, 'root : admin') ->addOption('pwd', null, Option::VALUE_REQUIRED, 'pwd : 123456') ->setDescription('the update resetPwd command'); } /** * @Author:Qinii * @Date: 2020/5/15 * @param Input $input * @param Output $output * @return int|void|null */ protected function execute(Input $input, Output $output) { $account = $input->getArgument('root'); if ($input->hasOption('pwd')){ $pwd = $input->getOption('pwd'); } $this->resetPwd($account,$pwd); } public function resetPwd($account,$pwd) { app()->make(AdminRepository::class)->resetPwd($account,$pwd); } }