function createConnectionObjectFromArgs(argList) {
  // check if ports and dbIndex given are valid, must be done here as redis connection params from cli are not added
  // to config object and tested later together with everything else from config
  let checkPortInvalid = function(portString, paramName) {
    if (portString) {
      if (Number.isNaN(portString) || !Number.isInteger(Number(portString))) {
        console.error(`value given for "${paramName}" is invalid - must be an integer number`);
        return true;
      }
      else if (Number(portString) < 1 || Number(portString) > 65535) {
        console.error(`value given for "${paramName}" is invalid - must be an integer number between 1 and 65535`);
        return true
      }
    }
    return false;
  };
  let checkDbIndexInvalid = function(dbString, paramName) {
    if (dbString) {
      if (Number.isNaN(dbString) || !Number.isInteger(Number(dbString))) {
        console.error(`value given for "${paramName}" is invalid - must be an integer number`);
        return true;
      }
      else if (Number(dbString) < 0) {
        console.error(`value given for "${paramName}" is invalid - must be an positiv integer number`);
        return true
      }
    }
    return false;
  };
  // sometimes redis_port is automatically set to something like 'tcp://10.2.3.4:6379'
  // parse this and update args accordingly
  if (typeof argList['redis-port'] === 'string' && argList['redis-port'].startsWith('tcp://')) {
    console.log('Found long tcp port descriptor with hostname in redis-port param, parse this as host and port value');
    let parts = argList['redis-port'].split(':');
    argList['redis-port'] = parts[2];
    argList['redis-host'] = parts[1].substring(2);
  }
  // now some validity checks - exits on failure with error message
  if (checkPortInvalid(argList['redis-port'], 'redis-port') ||
      checkPortInvalid(argList['sentinel-port'], 'sentinel-port') ||
      checkDbIndexInvalid(argList['redis-db'], 'redis-db')) {
    process.exit(1)
  }

  // now create connection object if enough params are set
  let connObj = null;
  if (argList['clusters'] || argList['sentinel-host'] || argList['sentinels'] || argList['redis-host'] || argList['redis-port'] || argList['redis-socket']
    || argList['redis-username'] || argList['redis-password'] || argList['redis-db']) {

    let db = parseInt(argList['redis-db']);
    connObj = {
      label: config.get('redis.defaultLabel'),
      dbIndex: Number.isNaN(db) ? 0 : db,
      username: argList['redis-username'] || null,
      password: argList['redis-password'] || '',
      connectionName: config.get('redis.connectionName'),
      optional: argList['redis-optional'],
      clusterNoTlsValidation: argList['clusterNoTlsValidation']
    };

    if (argList['redis-socket']) {
      connObj.path = argList['redis-socket'];
    }
    else {
      connObj.host = argList['redis-host'] || 'localhost';
      connObj.port = argList['redis-port'] || 6379;
      connObj.port = parseInt(connObj.port);
      connObj.isCluster = argList['is-cluster'];
      connObj.sentinelUsername = argList['sentinel-username'] || null;
      connObj.sentinelPassword = argList['sentinel-password'] || '';
      if (argList['sentinels']) {
        connObj.sentinels = myUtils.parseRedisServerList('--sentinels', argList['sentinels']);
        connObj.sentinelName = myUtils.getRedisSentinelGroupName(argList['sentinel-name']);
      }
      else if (argList['sentinel-host']) {
        connObj.sentinels = myUtils.parseRedisServerList('--sentinel-host or --sentinel-port',
          argList['sentinel-host'] + ':' + argList['sentinel-port']);
        connObj.sentinelName = myUtils.getRedisSentinelGroupName(argList['sentinel-name']);
      }
      else if (argList['clusters']) {
        connObj.clusters = myUtils.parseRedisServerList('--clusters', argList['clusters']);
      }
    }

    if (argList['redis-tls']) {
      // either basic tls support some special certs set and added to the tls config object
      connObj.tls = {};
      if (argList['redis-tls-ca-cert-file'] || argList['redis-tls-ca-cert']
          || argList['redis-tls-cert-file'] || argList['redis-tls-cert']
          || argList['redis-tls-key-file'] || argList['redis-tls-key']
          || argList['redis-tls-server-name']) {

        if (argList['redis-tls-ca-cert-file']) {
          connObj.tls.ca = fs.readFileSync(argList['redis-tls-ca-cert-file']);
        }
        else if (argList['redis-tls-ca-cert']) {
          connObj.tls.ca = argList['redis-tls-ca-cert'];
        }

        if (argList['redis-tls-cert-file']) {
          connObj.tls.cert = fs.readFileSync(argList['redis-tls-cert-file']);
        }
        else if (argList['redis-tls-cert']) {
          connObj.tls.cert = argList['redis-tls-cert'];
        }

        if (argList['redis-tls-key-file']) {
          connObj.tls.key = fs.readFileSync(argList['redis-tls-key-file']);
        }
        else if (argList['redis-tls-key']) {
          connObj.tls.key = argList['redis-tls-key'];
        }

        if (argList['redis-tls-server-name']) {
          connObj.tls.servername = argList['redis-tls-server-name'];
        }
      }

      if (argList['insecure-certificate']) {
        connObj.tls.rejectUnauthorized = false;
      }
    }

    // either set 'sentinel-tls' to a boolean value to reuse same tls settings as defined for Redis server
    // for Sentinel connections too
    // or use 'sentinel-tls' with optional 'sentinel-tls-*' settings to define some independent tls settings and
    // certificates to use and not reuse config for Redis server
    if (argList['sentinel-tls']) {
      connObj.enableTLSForSentinelMode = true;
      // either basic tls or complex tls support for sentinels, same meaning as for redis server itself
      connObj.sentinelTLS = {};
      if (argList['sentinel-tls-ca-cert-file'] || argList['sentinel-tls-ca-cert']
          || argList['sentinel-tls-cert-file'] || argList['sentinel-tls-cert']
          || argList['sentinel-tls-key-file'] || argList['sentinel-tls-key']
          || argList['sentinel-tls-server-name']) {

        if (argList['sentinel-tls-ca-cert-file']) {
          connObj.sentinelTLS.ca = fs.readFileSync(argList['sentinel-tls-ca-cert-file']);
        }
        else if (argList['sentinel-tls-ca-cert']) {
          connObj.sentinelTLS.ca = argList['sentinel-tls-ca-cert'];
        }

        if (argList['sentinel-tls-cert-file']) {
          connObj.sentinelTLS.cert = fs.readFileSync(argList['sentinel-tls-cert-file']);
        }
        else if (argList['sentinel-tls-cert']) {
          connObj.sentinelTLS.cert = argList['sentinel-tls-cert'];
        }

        if (argList['sentinel-tls-key-file']) {
          connObj.sentinelTLS.key = fs.readFileSync(argList['sentinel-tls-key-file']);
        }
        else if (argList['sentinel-tls-key']) {
          connObj.sentinelTLS.key = argList['sentinel-tls-key'];
        }

        if (argList['sentinel-tls-server-name']) {
          connObj.sentinelTLS.servername = argList['sentinel-tls-server-name'];
        }
      }
      else {
        // fallback if no special sentinel settings are defined - reuse redis one
        connObj.sentinelTLS = connObj.tls;

        if (argList['insecure-certificate']) {
          connObj.sentinelTLS.rejectUnauthorized = false;
        }
      }
    }
  }
  return connObj;
}
function to check command line arguments given if the contain vaid informations for an redis connection
 Some params like port and db are check if they are valid values (if set), otherwise the entire program will exit
 with an error message.

@param {object} argList object of params as given on command line as parsed by yargs
@return {null|object} returns "null" if no usable connection data are found, an object to feed into redis client
  otherwise to create a new connection.