From 3e518e3cf9547267a9e8acd09c19e94b1eafa4af Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sun, 14 Feb 2010 20:50:45 -0500 Subject: [PATCH] fixing long-flag-with-optional-part in optparse.coffee, and hiding bin/node_coffee --watch until we implement it --- lib/coffee_script/command_line.js | 5 ++++- lib/coffee_script/optparse.js | 3 ++- src/command_line.coffee | 2 +- src/optparse.coffee | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/coffee_script/command_line.js b/lib/coffee_script/command_line.js index b093b55a..3df7573b 100644 --- a/lib/coffee_script/command_line.js +++ b/lib/coffee_script/command_line.js @@ -5,7 +5,10 @@ coffee = require('coffee-script'); optparse = require('optparse'); BANNER = "coffee compiles CoffeeScript source files into JavaScript.\n\nUsage:\n coffee path/to/script.coffee"; - SWITCHES = [['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-r', '--run', 'compile and run a CoffeeScript'], ['-o', '--output [DIR]', 'set the directory for compiled JavaScript'], ['-w', '--watch', 'watch scripts for changes, and recompile'], ['-p', '--print', 'print the compiled JavaScript to stdout'], ['-l', '--lint', 'pipe the compiled JavaScript through JSLint'], ['-e', '--eval', 'compile a string from the command line'], ['-t', '--tokens', 'print the tokens that the lexer produces'], ['-tr', '--tree', 'print the parse tree that Jison produces'], ['-v', '--version', 'display CoffeeScript version'], ['-h', '--help', 'display this help message']]; + SWITCHES = [['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-r', '--run', 'compile and run a CoffeeScript'], ['-o', '--output [DIR]', 'set the directory for compiled JavaScript'], + // ['-w', '--watch', 'watch scripts for changes, and recompile'] + ['-p', '--print', 'print the compiled JavaScript to stdout'], ['-l', '--lint', 'pipe the compiled JavaScript through JSLint'], ['-e', '--eval', 'compile a string from the command line'], ['-t', '--tokens', 'print the tokens that the lexer produces'], ['-tr', '--tree', 'print the parse tree that Jison produces'], ['-v', '--version', 'display CoffeeScript version'], ['-h', '--help', 'display this help message'] + ]; WATCH_INTERVAL = 0.5; options = {}; sources = []; diff --git a/lib/coffee_script/optparse.js b/lib/coffee_script/optparse.js index d30ec5e2..64f212c5 100755 --- a/lib/coffee_script/optparse.js +++ b/lib/coffee_script/optparse.js @@ -89,8 +89,9 @@ build_rule = function build_rule(letter, flag, description) { var match; match = flag.match(OPTIONAL); + flag = flag.match(LONG_FLAG)[1]; return { - name: flag.match(LONG_FLAG)[1].substr(2), + name: flag.substr(2), letter: letter, flag: flag, description: description, diff --git a/src/command_line.coffee b/src/command_line.coffee index 237841be..5fd71eb9 100644 --- a/src/command_line.coffee +++ b/src/command_line.coffee @@ -14,7 +14,7 @@ SWITCHES: [ ['-i', '--interactive', 'run an interactive CoffeeScript REPL'] ['-r', '--run', 'compile and run a CoffeeScript'] ['-o', '--output [DIR]', 'set the directory for compiled JavaScript'] - ['-w', '--watch', 'watch scripts for changes, and recompile'] + # ['-w', '--watch', 'watch scripts for changes, and recompile'] ['-p', '--print', 'print the compiled JavaScript to stdout'] ['-l', '--lint', 'pipe the compiled JavaScript through JSLint'] ['-e', '--eval', 'compile a string from the command line'] diff --git a/src/optparse.coffee b/src/optparse.coffee index 14b847a6..ce481c23 100644 --- a/src/optparse.coffee +++ b/src/optparse.coffee @@ -59,8 +59,9 @@ build_rules: (rules) -> # Build a rule from a short-letter-flag, long-form-flag, and help text. build_rule: (letter, flag, description) -> match: flag.match(OPTIONAL) + flag: flag.match(LONG_FLAG)[1] { - name: flag.match(LONG_FLAG)[1].substr(2) + name: flag.substr(2) letter: letter flag: flag description: description