lib/config.js
function parseCommandLine(argv, config) {
  if (argv) {
    // read the command line arguments if no config file was given
    parseCommandLineArgument(argv.port, function(item){
      config.server.port = item;
    });

    parseCommandLineArgument(argv.html5mode, function(item){
      config.server.html5mode = item;
    });

    parseCommandLineArgument(argv._, function(item){
      config.server.webroot = path.normalize(item);
    });

    parseCommandLineArgument(argv.gateway, function(item){
      config.proxy.gateway = parseGateway(item);
    });

    parseCommandLineArgument(argv.forward, function(item){
      var rule = parseForwardRule(item);
      var match = false;

      config.proxy.forward.forEach(function(item) {
        if (item.regexp.source === rule.regexp.source) {
          item.target = rule.target;
          match = true;
        }
      });

      if (!match) {
        config.proxy.forward.push(rule);
      }
    });

    parseCommandLineArgument(argv.header, function(item){
      var rule = parseHeaderRule(item);
      var match = false;

      config.proxy.headers.forEach(function(item) {
        if (item.name === rule.name) {
          item.value = rule.value;
          match = true;
        }
      });

      if (!match) {
        config.proxy.headers.push(rule);
      }
    });
  }

  return config;
}
function parseCommandLine(argv, config) {
  if (argv) {
    // read the command line arguments if no config file was given
    parseCommandLineArgument(argv.port, function(item){
      config.server.port = item;
    });

    parseCommandLineArgument(argv.html5mode, function(item){
      config.server.html5mode = item;
    });

    parseCommandLineArgument(argv._, function(item){
      config.server.webroot = path.normalize(item);
    });

    parseCommandLineArgument(argv.gateway, function(item){
      config.proxy.gateway = parseGateway(item);
    });

    parseCommandLineArgument(argv.forward, function(item){
      var rule = parseForwardRule(item);
      var match = false;

      config.proxy.forward.forEach(function(item) {
        if (item.regexp.source === rule.regexp.source) {
          item.target = rule.target;
          match = true;
        }
      });

      if (!match) {
        config.proxy.forward.push(rule);
      }
    });

    parseCommandLineArgument(argv.header, function(item){
      var rule = parseHeaderRule(item);
      var match = false;

      config.proxy.headers.forEach(function(item) {
        if (item.name === rule.name) {
          item.value = rule.value;
          match = true;
        }
      });

      if (!match) {
        config.proxy.headers.push(rule);
      }
    });
  }

  return config;
}
function parseCommandLine ( argv , config ) { if ( argv ) { // read the command line arguments if no config file was given parseCommandLineArgument ( argv . port , function ( item ) { config . server . port = item ; } ) ; parseCommandLineArgument ( argv . html5mode , function ( item ) { config . server . html5mode = item ; } ) ; parseCommandLineArgument ( argv . _ , function ( item ) { config . server . webroot = path . normalize ( item ) ; } ) ; parseCommandLineArgument ( argv . gateway , function ( item ) { config . proxy . gateway = parseGateway ( item ) ; } ) ; parseCommandLineArgument ( argv . forward , function ( item ) { var rule = parseForwardRule ( item ) ; var match = false ; config . proxy . forward . forEach ( function ( item ) { if ( item . regexp . source === rule . regexp . source ) { item . target = rule . target ; match = true ; } } ) ; if ( ! match ) { config . proxy . forward . push ( rule ) ; } } ) ; parseCommandLineArgument ( argv . header , function ( item ) { var rule = parseHeaderRule ( item ) ; var match = false ; config . proxy . headers . forEach ( function ( item ) { if ( item . name === rule . name ) { item . value = rule . value ; match = true ; } } ) ; if ( ! match ) { config . proxy . headers . push ( rule ) ; } } ) ; } return config ; }
reads command line parameters
reads command line parameters