<?php

namespace UtilityModule\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use UtilityModule\Service\AuthService;

class GeneratePasswordHash extends Command
{
    /** @var AuthService */
    private $authService;

    public function __construct(AuthService $authService)
    {
        $this->authService = $authService;
        parent::__construct();
    }

    protected function configure()
    {
        $this->setName('password:generate')
            ->setDescription('Generate a password hash')
            ->addArgument('password', InputArgument::REQUIRED, 'Password to hash');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $pass = $input->getArgument('password');
        $output->writeln($this->authService->createPasswordHash($pass));
    }
}
