namespace Illuminate\Console;

use Illuminate\Contracts\Support\Arrayable;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
// more namespace
class Command extends SymfonyCommand
{
/**
* The Laravel application instance.
*
* @var \Illuminate\Contracts\Foundation\Application
*/
protected $laravel;// the big or base instance.

/**
* The input interface implementation.
*
* @var \Symfony\Component\Console\Input\InputInterface
*/
protected $input;// The input interface implementation.

/**
* The output interface implementation.
*
* @var \Illuminate\Console\OutputStyle
*/
protected $output;// The output interface implementation.

/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature;// The name and signature of the console command ,like a token

/**
* The console command name.
*
* @var string
*/
protected $name;// command name,like a key

/**
* The console command description.
*
* @var string
*/
protected $description;// command description

/**
* The default verbosity of output commands. // the detail about the output commands.
* verbosity == detail
* @var int
*/
protected $verbosity = OutputInterface::VERBOSITY_NORMAL;// this is "32"

/**
* The mapping between human readable verbosity levels and Symfony's OutputInterface.
*
* @var array
*/
protected $verbosityMap = [
'v' => OutputInterface::VERBOSITY_VERBOSE,
'vv' => OutputInterface::VERBOSITY_VERY_VERBOSE,
'vvv' => OutputInterface::VERBOSITY_DEBUG,
'quiet' => OutputInterface::VERBOSITY_QUIET,
'normal' => OutputInterface::VERBOSITY_NORMAL,
];// a array to change the flag to a human can read flag

/**
* Create a new console command instance.
*
* @return void
*/
public function __construct()
{
// We will go ahead and set the name, description, and parameters on console
// commands just to make things a little easier on the developer. This is
// so they don't have to all be manually specified in the constructors.
if (isset($this->signature)) {
$this->configureUsingFluentDefinition();
} else {
parent::__construct($this->name);
}// two way , one is configureUsingFluentDefinition
// anther use father __construct

$this->setDescription($this->description);// Set Description

if (! isset($this->signature)) {
$this->specifyParameters();// set the specify Parameters.
}
}// create a new console command instance
// we will go ahead and set the name , description, and parameters on console commands to make a little easier on the developer.
// This is so they don't have to all be manually specified in the constructors.

/**
* Configure the console command using a fluent definition.
*
* @return void
*/
protected function configureUsingFluentDefinition()
{
list($name, $arguments, $options) = Parser::parse($this->signature);// set the parser::parse();

parent::__construct($name);// use father __construct(); with a variable

foreach ($arguments as $argument) {
$this->getDefinition()->addArgument($argument);
}// this is a addArgument ($argument)
// set the argument

foreach ($options as $option) {
$this->getDefinition()->addOption($option);
}// set the option
}// configure the console command using a definition

/**
* Specify the arguments and options on the command.
*
* @return void
*/
protected function specifyParameters()// register arguments and options
{
// We will loop through all of the arguments and options for the command and
// set them all on the base command instance. This specifies what can get
// passed into these commands as "parameters" to control the execution.
foreach ($this->getArguments() as $arguments) {
call_user_func_array([$this, 'addArgument'], $arguments);
}// call the argument function to add the argments

foreach ($this->getOptions() as $options) {
call_user_func_array([$this, 'addOption'], $options);
}// call the addOption function to add the options
}// send the right arguments and options to the command.
// we will loop through all of the arguments and options for the command and set them all on the base command instance.
// This specifies what can get passed into these commands as "parameters" to control the execution

/**
* Run the console command.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int
*/
public function run(InputInterface $input, OutputInterface $output)
{
$this->input = $input;// get input

$this->output = new OutputStyle($input, $output);// get output

return parent::run($input, $output);// use parent::run();
}// Run the console command.

/**
* Execute the console command.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return mixed
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$method = method_exists($this, 'handle') ? 'handle' : 'fire';// check the way to start,

return $this->laravel->call([$this, $method]);// never use the arguments
}// a normal call the function, be ley mysql execute,
// execute the console command.