From 7d348b5eaed80dc5cb66a6b2539a6fe6ef6d14c9 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sat, 13 Feb 2010 10:07:59 -0500 Subject: [PATCH] display the usage message when called without arguments --- lib/coffee_script/command_line.js | 4 ++++ src/command_line.coffee | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/coffee_script/command_line.js b/lib/coffee_script/command_line.js index 5ccc7f4d..9304f69c 100644 --- a/lib/coffee_script/command_line.js +++ b/lib/coffee_script/command_line.js @@ -10,6 +10,9 @@ // The CommandLine handles all of the functionality of the `coffee` utility. exports.run = function run() { this.parse_options(); + if (!(this.sources.length)) { + this.usage(); + } this.compile_scripts(); return this; }; @@ -113,6 +116,7 @@ var oparser, opts, paths; opts = (this.options = {}); oparser = (this.option_parser = new optparse.OptionParser(SWITCHES)); + oparser.banner = BANNER; oparser.add = oparser['on']; oparser.add('interactive', function() { return opts.interactive = true; diff --git a/src/command_line.coffee b/src/command_line.coffee index 33b495bf..11dc2466 100644 --- a/src/command_line.coffee +++ b/src/command_line.coffee @@ -31,6 +31,7 @@ WATCH_INTERVAL: 0.5 # The CommandLine handles all of the functionality of the `coffee` utility. exports.run: -> @parse_options() + @usage() unless @sources.length @compile_scripts() this @@ -99,9 +100,10 @@ exports.lint: (js) -> # Use OptionParser for all the options. exports.parse_options: -> - opts: @options: {} - oparser: @option_parser: new optparse.OptionParser SWITCHES - oparser.add: oparser['on'] + opts: @options: {} + oparser: @option_parser: new optparse.OptionParser SWITCHES + oparser.banner: BANNER + oparser.add: oparser['on'] oparser.add 'interactive', -> opts.interactive: true oparser.add 'run', -> opts.run: true