public function add(Command $command, string $alias = '', bool $default = false): self
    {
        $name = $command->name();

        if ($this->commands[$name] ?? $this->aliases[$name] ?? $this->commands[$alias] ?? $this->aliases[$alias] ?? null) {
            throw new InvalidArgumentException(\sprintf('Command "%s" already added', $name));
        }

        if ($alias) {
            $command->alias($alias);
            $this->aliases[$alias] = $name;
        }

        if ($default) {
            $this->default = $name;
        }

        $this->commands[$name] = $command->version($this->version)->onExit($this->onExit)->bind($this);

        return $this;
    }
public function add(Command $command, string $alias = '', bool $default = false): self
    {
        $name = $command->name();

        if ($this->commands[$name] ?? $this->aliases[$name] ?? $this->commands[$alias] ?? $this->aliases[$alias] ?? null) {
            throw new InvalidArgumentException(\sprintf('Command "%s" already added', $name));
        }

        if ($alias) {
            $command->alias($alias);
            $this->aliases[$alias] = $name;
        }

        if ($default) {
            $this->default = $name;
        }

        $this->commands[$name] = $command->version($this->version)->onExit($this->onExit)->bind($this);

        return $this;
    }
public function add ( Command $ command , string $ alias = '' , bool $ default = false ) : self { $ name = $ command -> name ( ) ; if ( $ this -> commands [ $ name ] ?? $ this -> aliases [ $ name ] ?? $ this -> commands [ $ alias ] ?? $ this -> aliases [ $ alias ] ?? null ) { throw new InvalidArgumentException ( \ sprintf ( 'Command "%s" already added' , $ name ) ) ; } if ( $ alias ) { $ command -> alias ( $ alias ) ; $ this -> aliases [ $ alias ] = $ name ; } if ( $ default ) { $ this -> default = $ name ; } $ this -> commands [ $ name ] = $ command -> version ( $ this -> version ) -> onExit ( $ this -> onExit ) -> bind ( $ this ) ; return $ this ; }
Add a prepred command.

@param Command $command
@param string  $alias
@param bool    $default

@return self
Add a prepred command .