original_string: public function addArgument($name, array $params = [])
      {
          if ($name instanceof ConsoleInputArgument) {
              $arg = $name;
              $index = count($this->_args);
          } else {
              $defaults = [
                  'name' => $name,
                  'help' => '',
                  'index' => count($this->_args),
                  'required' => false,
                  'choices' => []
              ];
              $options = $params + $defaults;
              $index = $options['index'];
              unset($options['index']);
              $arg = new ConsoleInputArgument($options);
          }
          foreach ($this->_args as $k => $a) {
              if ($a->isEqualTo($arg)) {
                  return $this;
              }
              if (!empty($options['required']) && !$a->isRequired()) {
                  throw new LogicException('A required argument cannot follow an optional one');
              }
          }
          $this->_args[$index] = $arg;
          ksort($this->_args);
  
          return $this;
      }
code: public function addArgument($name, array $params = [])
      {
          if ($name instanceof ConsoleInputArgument) {
              $arg = $name;
              $index = count($this->_args);
          } else {
              $defaults = [
                  'name' => $name,
                  'help' => '',
                  'index' => count($this->_args),
                  'required' => false,
                  'choices' => []
              ];
              $options = $params + $defaults;
              $index = $options['index'];
              unset($options['index']);
              $arg = new ConsoleInputArgument($options);
          }
          foreach ($this->_args as $k => $a) {
              if ($a->isEqualTo($arg)) {
                  return $this;
              }
              if (!empty($options['required']) && !$a->isRequired()) {
                  throw new LogicException('A required argument cannot follow an optional one');
              }
          }
          $this->_args[$index] = $arg;
          ksort($this->_args);
  
          return $this;
      }
code_tokens: public function addArgument ( $ name , array $ params = [ ] ) { if ( $ name instanceof ConsoleInputArgument ) { $ arg = $ name ; $ index = count ( $ this -> _args ) ; } else { $ defaults = [ 'name' => $ name , 'help' => '' , 'index' => count ( $ this -> _args ) , 'required' => false , 'choices' => [ ] ] ; $ options = $ params + $ defaults ; $ index = $ options [ 'index' ] ; unset ( $ options [ 'index' ] ) ; $ arg = new ConsoleInputArgument ( $ options ) ; } foreach ( $ this -> _args as $ k => $ a ) { if ( $ a -> isEqualTo ( $ arg ) ) { return $ this ; } if ( ! empty ( $ options [ 'required' ] ) && ! $ a -> isRequired ( ) ) { throw new LogicException ( 'A required argument cannot follow an optional one' ) ; } } $ this -> _args [ $ index ] = $ arg ; ksort ( $ this -> _args ) ; return $ this ; }
docstring: Add a positional argument to the option parser.
  
  ### Params
  
  - `help` The help text to display for this argument.
  - `required` Whether this parameter is required.
  - `index` The index for the arg, if left undefined the argument will be put
  onto the end of the arguments. If you define the same index twice the first
  option will be overwritten.
  - `choices` A list of valid choices for this argument. If left empty all values are valid..
  An exception will be raised when parse() encounters an invalid value.
  
  @param \Cake\Console\ConsoleInputArgument|string $name The name of the argument.
  Will also accept an instance of ConsoleInputArgument.
  @param array $params Parameters for the argument, see above.
  @return $this
docstring_tokens: Add a positional argument to the option parser .