var spawn = require('child_process').spawn;
var path = require('path');

module.exports = function (options) {
    options = options || {};
    options.url = options.url || 'http://nodejs.org';
    options.name = options.name || 'nodejs';

    var client;
    switch (process.platform) {
    case 'win32':
        client = path.resolve(__dirname + '/cefclient/cefclient');
        break;
    case 'linux':
        client = path.resolve(__dirname + '/build/default/topcube');
        break;
    default:
        console.warn('');
        return null;
        break;
    }

    var args = [];
    for (var key in options) args.push('--' + key + '=' + options[key]);

    var child = spawn(client, args);
    child.on('exit', function(code) {
        process.exit(code);
    });
    child.stdout.pipe(process.stdout);
    child.stderr.pipe(process.stderr);
    return child;
};


var spawn = require('child_process').spawn;
var path = require('path');

module.exports = function (options) {
    options = options || {};
    options.url = options.url || 'http://nodejs.org';
    options.name = options.name || 'nodejs';

    var client;
    var keys = [];
    switch (process.platform) {
    case 'win32':
        client = path.resolve(__dirname + '/cefclient/cefclient');
        keys = ['url', 'name', 'width', 'height', 'minwidth', 'minheight', 'ico'];
        break;
    case 'linux':
        client = path.resolve(__dirname + '/build/default/topcube');
        keys = ['url', 'name', 'width', 'height', 'minwidth', 'minheight'];
        break;
    default:
        console.warn('');
        return null;
        break;
    }

    var args = [];
    for (var key in options) {
        if (keys.indexOf(key) !== -1) {
            args.push('--' + key + '=' + options[key]);
        }
    }

    var child = spawn(client, args);
    child.on('exit', function(code) {
        process.exit(code);
    });
    child.stdout.pipe(process.stdout);
    child.stderr.pipe(process.stderr);
    return child;
};


Define valid keys per platform and filter out invalid options.
Define valid keys per platform and filter out invalid options.
