Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Command.php

function Command::addArgument

Adds an argument.

Parameters

$mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL:

$default The default value (for InputArgument::OPTIONAL mode only):

array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion:

Return value

$this

Throws

InvalidArgumentException When argument mode is not valid

2 methods override Command::addArgument()
LazyCommand::addArgument in vendor/symfony/console/Command/LazyCommand.php
TraceableCommand::addArgument in vendor/symfony/console/Command/TraceableCommand.php
Adds an argument.

File

vendor/symfony/console/Command/Command.php, line 412

Class

Command
Base class for all commands.

Namespace

Symfony\Component\Console\Command

Code

public function addArgument(string $name, ?int $mode = null, string $description = '', mixed $default = null, array|\Closure $suggestedValues = []) : static {
    $this->definition
        ->addArgument(new InputArgument($name, $mode, $description, $default, $suggestedValues));
    $this->fullDefinition?->addArgument(new InputArgument($name, $mode, $description, $default, $suggestedValues));
    return $this;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal