arguable.js
function Arguable (usage, argv, options) {
    this._usage = usage

    // These are the merged defintion and invocation options provided by the
    // user.
    this.options = options.options

    // The key used to create the `Destructible`.
    this.identifier = options.identifier

    // We'll use this for an exit code if it is set and if we exit normally.
    this.exitCode = null

    // Are we running as a main module?
    this.isMainModule = options.isMainModule

    // Use environment `LANG` or else language of first usage definition.
    this.lang = coalesce(options.lang, this._usage.language)

    // Extract argument patterns from usage.
    var patterns = this._usage.getPattern()

    // Extract the arguments that accept values, TODO maybe call `valuable`.
    this.arguable = patterns.filter(function (pattern) {
        return pattern.arguable
    }).map(function (pattern) {
        return pattern.verbose
    })

    // Parse arguments and save the remaining arguments.
    try {
        var gotopts = getopt(patterns, argv)
    } catch (error) {
        this.abend(error.abend, error.context)
    }

    // Extract an argument end sigil and note that it was there.
    if (this.terminal = argv[0] == '--')  {
        argv.shift()
    }

    // Slice and dice results into convenience structures.
    this._setParameters(gotopts)

    // Remaining arguments.
    this.argv = argv

    // Assign standard I/O provide in `options`.
    this.stdout = options.stdout
    this.stderr = options.stderr
    this.stdin = options.stdin

    // Assign pipes open to our parent.
    this.pipes = options.pipes

    // Set after we get our arguments.
    this.scram = 0

    // Called when we exit with no arguments.
    this.exited = new Signal
}
function Arguable (usage, argv, options) {
    this._usage = usage

    // These are the merged defintion and invocation options provided by the
    // user.
    this.options = options.options

    // The key used to create the `Destructible`.
    this.identifier = options.identifier

    // We'll use this for an exit code if it is set and if we exit normally.
    this.exitCode = null

    // Are we running as a main module?
    this.isMainModule = options.isMainModule

    // Use environment `LANG` or else language of first usage definition.
    this.lang = coalesce(options.lang, this._usage.language)

    // Extract argument patterns from usage.
    var patterns = this._usage.getPattern()

    // Extract the arguments that accept values, TODO maybe call `valuable`.
    this.arguable = patterns.filter(function (pattern) {
        return pattern.arguable
    }).map(function (pattern) {
        return pattern.verbose
    })

    // Parse arguments and save the remaining arguments.
    try {
        var gotopts = getopt(patterns, argv)
    } catch (error) {
        this.abend(error.abend, error.context)
    }

    // Extract an argument end sigil and note that it was there.
    if (this.terminal = argv[0] == '--')  {
        argv.shift()
    }

    // Slice and dice results into convenience structures.
    this._setParameters(gotopts)

    // Remaining arguments.
    this.argv = argv

    // Assign standard I/O provide in `options`.
    this.stdout = options.stdout
    this.stderr = options.stderr
    this.stdin = options.stdin

    // Assign pipes open to our parent.
    this.pipes = options.pipes

    // Set after we get our arguments.
    this.scram = 0

    // Called when we exit with no arguments.
    this.exited = new Signal
}
function Arguable ( usage , argv , options ) { this . _usage = usage // These are the merged defintion and invocation options provided by the // user. this . options = options . options // The key used to create the `Destructible`. this . identifier = options . identifier // We'll use this for an exit code if it is set and if we exit normally. this . exitCode = null // Are we running as a main module? this . isMainModule = options . isMainModule // Use environment `LANG` or else language of first usage definition. this . lang = coalesce ( options . lang , this . _usage . language ) // Extract argument patterns from usage. var patterns = this . _usage . getPattern ( ) // Extract the arguments that accept values, TODO maybe call `valuable`. this . arguable = patterns . filter ( function ( pattern ) { return pattern . arguable } ) . map ( function ( pattern ) { return pattern . verbose } ) // Parse arguments and save the remaining arguments. try { var gotopts = getopt ( patterns , argv ) } catch ( error ) { this . abend ( error . abend , error . context ) } // Extract an argument end sigil and note that it was there. if ( this . terminal = argv [ 0 ] == '--' ) { argv . shift ( ) } // Slice and dice results into convenience structures. this . _setParameters ( gotopts ) // Remaining arguments. this . argv = argv // Assign standard I/O provide in `options`. this . stdout = options . stdout this . stderr = options . stderr this . stdin = options . stdin // Assign pipes open to our parent. this . pipes = options . pipes // Set after we get our arguments. this . scram = 0 // Called when we exit with no arguments. this . exited = new Signal }
This will never be pretty. Let it be ugly. Let it swallow all the sins before they enter your program, so that your program can be a garden of pure ideology.
This will never be pretty . Let it be ugly . Let it swallow all the sins before they enter your program so that your program can be a garden of pure ideology .