public function getDbCommandArgs($command, array $database, $schema = null)
    {
        if ($schema === null) {
            $schema = $database['path'];
        }

        switch ($command) {
            case 'psql':
            case 'pg_dump':
                $url = sprintf(
                    'postgresql://%s:%s@%s:%d',
                    $database['username'],
                    $database['password'],
                    $database['host'],
                    $database['port']
                );
                if ($schema !== '') {
                    $url .= '/' . rawurlencode($schema);
                }

                return OsUtil::escapePosixShellArg($url);

            case 'mysql':
            case 'mysqldump':
                $args = sprintf(
                    '--user=%s --password=%s --host=%s --port=%d',
                    OsUtil::escapePosixShellArg($database['username']),
                    OsUtil::escapePosixShellArg($database['password']),
                    OsUtil::escapePosixShellArg($database['host']),
                    $database['port']
                );
                if ($schema !== '') {
                    $args .= ' ' . OsUtil::escapePosixShellArg($schema);
                }

                return $args;

            case 'mongo':
            case 'mongodump':
            case 'mongoexport':
            case 'mongorestore':
                $args = sprintf(
                    '--username %s --password %s --host %s --port %d',
                    OsUtil::escapePosixShellArg($database['username']),
                    OsUtil::escapePosixShellArg($database['password']),
                    OsUtil::escapePosixShellArg($database['host']),
                    $database['port']
                );
                if ($schema !== '') {
                    $args .= ' --authenticationDatabase ' . OsUtil::escapePosixShellArg($schema);
                    if ($command === 'mongo') {
                        $args .= ' ' . OsUtil::escapePosixShellArg($schema);
                    } else {
                        $args .= ' --db ' . OsUtil::escapePosixShellArg($schema);
                    }
                }

                return $args;
        }

        throw new \InvalidArgumentException('Unrecognised command: ' . $command);
    }