nl_tokens: HACK : Process arguments so that in interpret mode commander . js only parses the flags without the file name and anything past that . If an invalid flag is encountered commander . js error reporting is emulated instead .
pl_tokens: function processArguments ( argv ) { // Preserve the original. argv = argv . slice ( ) ; var interpretMode = true ; for ( var i = 2 ; i < argv . length ; i ++ ) { var arg = argv [ i ] , index ; if ( arg === '--' ) break ; // Normalize flags in-place. if ( arg . length > 2 && arg [ 0 ] === '-' && arg [ 1 ] !== '-' ) { // TODO: Is this needed at all for traceur? arg = arg . slice ( 1 ) . split ( '' ) . map ( function ( flag ) { return '-' + flag ; } ) ; // Insert the normalized flags in argv. argv . splice . apply ( argv , [ i , 1 ] . concat ( arg ) ) ; // Grab the first normalized flag and process it as usual. arg = argv [ i ] ; } else if ( / ^-- / . test ( arg ) && ( index = arg . indexOf ( '=' ) ) !== - 1 ) { // Insert the flag argument in argv. argv . splice ( i + 1 , 0 , arg . slice ( index + 1 ) ) ; // Replace the flag with the stripped version and process it as usual. arg = argv [ i ] = arg . slice ( 0 , index ) ; } var option = flags . optionFor ( arg ) ; if ( option ) { if ( arg === '--out' || arg === '--dir' ) interpretMode = false ; if ( option . required ) i ++ ; else if ( <mask> . optional ) { arg = argv [ i + 1 ] ; if ( arg && arg [ 0 ] !== '-' ) i ++ ; } } else if ( arg === '-h' || arg === '--help' ) { // HACK: Special case for the implicit help flags, which can't have // their own option, as --help would set flags.help to true, shadowing // the flags.help() method. } else if ( arg [ 0 ] === '-' ) { // HACK: Because commander.js has a flexible policy, this is the only // reliable way of reporting invalid flags to the user, and it's limited // to the first invalid flag encountered. console . log ( '\n  error: unknown option `%s\'\n' , arg ) ; process . exit ( 1 ) ; } else if ( interpretMode ) { // Add a hint to stop commander.js from parsing following arguments. // Note that this means that --out must come before any unknown flag as // well as before any filename for it to be used as the out flag. argv . splice ( i , 0 , '--' ) ; // Save traceur flags for interpret.js. argv . flags = argv . slice ( 2 , i ) ; break ; } } return argv ; }