Add missing definition options to the command usually defined by the application.

See also composer/composer in src/Composer/Console/Application.php

@param BaseCommand $command The command to fix.

@return void
971524
protected function fixCommandDefinition(BaseCommand $command)
    {
        $definition = $command->getDefinition();

        if (!$definition->hasOption('verbose')) {
            $definition->addOption(
                new InputOption(
                    'verbose',
                    'v|vv|vvv',
                    InputOption::VALUE_NONE,
                    'Shows more details including new commits pulled in when updating packages.'
                )
            );
        }
        if (!$definition->hasOption('profile')) {
            $definition->addOption(
                new InputOption(
                    'profile',
                    null,
                    InputOption::VALUE_NONE,
                    'Display timing and memory usage information'
                )
            );
        }
        if (!$definition->hasOption('no-plugins')) {
            $definition->addOption(
                new InputOption(
                    'no-plugins',
                    null,
                    InputOption::VALUE_NONE,
                    'Whether to disable plugins.'
                )
            );
        }
        if (!$definition->hasOption('working-dir')) {
            $definition->addOption(
                new InputOption(
                    'working-dir',
                    '-d',
                    InputOption::VALUE_REQUIRED,
                    'If specified, use the given directory as working directory.'
                )
            );
        }
    }
691945
public function validate(BaseCommand $command)
  {
    if(isset(static::$rules) && is_array(static::$rules))
      $rules = static::$rules;
    elseif(isset(static::$rules) && Str::startsWith(static::$rules, '@'))
      $rules = $this->{substr(static::$rules, 1)}($command);
    else
      $rules = [];

    $validation = $this->validator->make($command->all(), $rules);

    if($validation->fails())
    {
      $this->throwException($validation);
    }
  }
1036292
public function add(SymfonyCommand $command)
	{
		if ($command instanceof Command)
		{
			$command->setFlyphp($this->flyphp);
		}

		return $this->addToParent($command);
	}
344069
public static function configure(Command $command)
    {
        $command->setName('migrations:list')
            ->setDescription('Prints version IDs for all available migrations ordered incrementally.')
            ->addOption(
                'newest-first',
                null,
                InputOption::VALUE_NONE,
                'Sort list in reverse order (newest first)'
            );
    }
692019
protected function registerMakeAddonCommand($command)
    {
        $this->app->singleton($command, function ($app) {
            return new Addons\Commands\AddonMakeCommand($app);
        });
    }
958712
final public function handle(Command $command): void
    {
        $supportedCommandType = $this->getSupportedCommandType();
        if (!\is_a($command, $supportedCommandType)) {
            throw new InvalidCommandException(\sprintf(
                'Command must be a %s, %s given',
                $supportedCommandType,
                \get_class($command)
            ));
        }

        $this->handleCommand($command);
    }
77930
protected function registerMakeMigrationCommand($command)
    {
        $this->app->singleton($command, function ($app) {
            return new Database\Commands\MigrationMakeCommand($app);
        });
    }
1123657
public function addTasks($command)
	{
		$this->addSection('Tasks');

		$class = new \ReflectionClass($command);
		$tasks = $class->getMethods(\ReflectionMethod::IS_PUBLIC);

		if ($tasks && count($tasks) > 0)
		{
			$list = [];
			$max  = 0;

			foreach ($tasks as $task)
			{
				if (!$task->isConstructor() && $task->name != 'execute' && $task->name != 'help')
				{
					$comment     = $task->getDocComment();
					$description = 'no description available';

					// Check for help ignore flag
					preg_match('/@museDescription ([[:alnum:] ,\.()\-\'\/]*)/', $comment, $matched);

					if ($matched && isset($matched[1]))
					{
						$description = trim($matched[1]);
					}

					$list[] = [
						'name'        => $task->name,
						'description' => $description
					];

					$max    = ($max > strlen($task->name)) ? $max : strlen($task->name);
				}
			}

			if (count($list) > 0)
			{
				foreach ($list as $item)
				{
					$this->addString($item['name'], [
						'color'       => 'blue',
						'indentation' => 2
					]);

					$this->addString(str_repeat(' ', ($max - strlen($item['name']))) . '   ');
					$this->addLine($item['description']);
				}
			}
			else
			{
				$this->addLine('There are no tasks available for this command', [
					'color'       => 'red',
					'indentation' => 2
				]);
			}
		}

		$this->addSpacer();

		return $this;
	}
1157029
protected function _buildCommand($command)
    {
        $url = $command->receiver->getURL();

        $command->setAttribute('data-action', $command->action);
        $command->setAttribute('data-actor', $command->actor->id);

        if (!$this->_use_post && $this->getController()->getRequest()->getFormat() != 'json') {
            $url .= '&layout=list';
        }

        $command->href($url);
    }
551186
public function addCommand($command, $config = array())
    {
        if (! ($command instanceof  AnControllerToolbarCommand)) {
            $command = $this->getCommand($command, $config);
        }

        $this->_commands[$command->getName()] = $command;
        return $this;
    }
666681
public function addCommand($command, $config = array())
    {
        if (!($command instanceof KControllerToolbarCommandInterface)) {
            $command = $this->getCommand($command, $config);
        }

        //Set the command parent
        $command->setParent($this);

        $this->_commands[$command->getName()] = $command;
        return $command;
    }
316016
public function drush($command) {
    // Clear out options associated with previous drush command.
    $this->setOptionsForLastCommand();

    if (!$this->defaultsInitialized) {
      $this->init();
    }

    if (is_array($command)) {
      $command = implode(' ', array_filter($command));
    }

    $this->commands[] = trim($command);
    return $this;
  }
538631
public function showHelpInfo(string $command = ''): void
    {
        /** @var \Inhere\Console\IO\Input $in */
        $in = $this->input;

        // display help for a special command
        if ($command) {
            $in->setCommand($command);
            $in->setSOpt('h', true);
            $in->clearArgs();
            $this->dispatch($command);
            return;
        }

        $sep    = $this->delimiter;
        $script = $in->getScript();

        /** @var \Inhere\Console\IO\Output $out */
        $out = $this->output;
        $out->helpPanel([
            'usage'   => "$script <info>{command}</info> [--opt -v -h ...] [arg0 arg1 arg2=value2 ...]",
            'example' => [
                "$script test (run a independent command)",
                "$script home{$sep}index (run a command of the group)",
                "$script help {command} (see a command help information)",
                "$script home{$sep}index -h (see a command help of the group)",
                "$script --auto-completion --shell-env [zsh|bash] [--gen-file stdout]",
            ]
        ]);
    }
1274184
private function setShellCommand($command)
    {
        if (! isset($command)) {
            throw new InvalidArgumentException('Must define a command.');
        }

        if (isset($this->shellCommand) && $this->shellCommand !== $command) {
            throw new LogicException('Cannot redefine command once set!');
        }

        $this->shellCommand = $command;

        return $this;
    }
1210691
public function addCommand($command, $config = array())
    {
        if (!($command instanceof ControllerToolbarCommand)) {
            $command = $this->getCommand($command, $config);
        }

        return $this->getDelegate()->addCommand($command, $config);
    }
1215145
protected function registerAddonNameCommand($command)
    {
        $this->app->singleton($command, function ($app) {
            return new Addons\Commands\AddonNameCommand($app);
        });
    }
1293239
public function setCommand($command)
    {
        if (!preg_match(self::$_regex['command'], $command)) {
            throw new \InvalidArgumentException(sprintf('Command "%s" is incorect', $command));
        }

        $this->command = $command;

        return $this->generateHash();
    }