function option(name, flags, coercion, settings)
{
    settings = extend(
        {
            'variable': null,
            'default':  null,
            'help':     '',
            'required': false,
            'action':   function() {}
        },
        settings
    );

    this.name = name;
    this.data = null;
    this.flags = [];
    this.variable = null;
    this.settings = settings;
    this.validators = [];

    this.coercion = (typeof coercion === 'function'
                        ? coercion
                        : function(_, _) { return coercion; });

    flags.split(/[, |]+/).forEach(function(part) {
        var match;

        if (/^-[a-z0-9]$/i.test(part)) {
            this.flags.push(part);
        } else if (/^--[a-z][a-z0-9-]+$/i.test(part)) {
            this.flags.push(part);
        } else if ((match = part.match(/^<([^>]+)>$/))) {
            this.variable = (settings.variable !== null ? settings.variable : match[1]);
        } else {
            throw 'unexpected string "' + part + '"';
        }
    }, this);

}
/**
 * Constructor.
 *
 * @param   string          name            Name of option.
 * @param   string          flags           Option flags.
 * @param   callable|mixed  coercion        Either a coercion callback or a fixed value.
 * @param   object          settings        Optional additional settings.
 */
Constructor.
@param   string          name            Name of option.
@param   string          flags           Option flags.
@param   callable|mixed  coercion        Either a coercion callback or a fixed value.
@param   object          settings        Optional additional settings.
Constructor . @param string name Name of option . @param string flags Option flags . @param callable|mixed coercion Either a coercion callback or a fixed value . @param object settings Optional additional settings .
function option(name, flags, coercion, settings)
{
    settings = extend(
        {
            'variable': null,
            'default':  null,
            'help':     '',
            'required': false,
            'action':   function() {}
        },
        settings
    );
    this.name = name;
    this.data = null;
    this.flags = [];
    this.variable = null;
    this.settings = settings;
    this.validators = [];
    this.coercion = (typeof coercion === 'function'
                        ? coercion
                        : function(_, _) { return coercion; });
    flags.split(/[, |]+/).forEach(function(part) {
        var match;
        if (/^-[a-z0-9]$/i.test(part)) {
            this.flags.push(part);
        } else if (/^--[a-z][a-z0-9-]+$/i.test(part)) {
            this.flags.push(part);
        } else if ((match = part.match(/^<([^>]+)>$/))) {
            this.variable = (settings.variable !== null ? settings.variable : match[1]);
        } else {
            throw 'unexpected string "' + part + '"';
        }
    }, this);
}
function option ( name , flags , coercion , settings ) { settings = extend ( { 'variable' : null , 'default' : null , 'help' : '' , 'required' : false , 'action' : function ( ) { } } , settings ) ; this . name = name ; this . data = null ; this . flags = [ ] ; this . variable = null ; this . settings = settings ; this . validators = [ ] ; this . coercion = ( typeof coercion === 'function' ? coercion : function ( _ , _ ) { return coercion ; } ) ; flags . split ( / [, |]+ / ) . forEach ( function ( part ) { var match ; if ( / ^-[a-z0-9]$ / i . test ( part ) ) { this . flags . push ( part ) ; } else if ( / ^--[a-z][a-z0-9-]+$ / i . test ( part ) ) { this . flags . push ( part ) ; } else if ( ( match = part . match ( / ^<([^>]+)>$ / ) ) ) { this . variable = ( settings . variable !== null ? settings . variable : match [ 1 ] ) ; } else { throw 'unexpected string "' + part + '"' ; } } , this ) ; }
Constructor.
Constructor .