Class: NScript::CommandLine

Inherits:
Object
  • Object
show all
Defined in:
lib/nscript/command_line.rb

Overview

The CommandLine handles all of the functionality of the ‘nscript` utility.

Constant Summary collapse

<<-EOS
nscript compiles NScript source files into JavaScript.

Usage:
  nscript path/to/script.ns
EOS
WATCH_INTERVAL =

Seconds to pause between checks for changed source files.

0.5
ROOT =

Path to the root of the NScript install.

File.expand_path(File.dirname(__FILE__) + '/../..')
RUNNERS =

Commands to execute NScripts.

{
  :node     => "node #{ROOT}/lib/nscript/runner.js",
  :narwhal  => "narwhal -p #{ROOT} -e 'require(\"nscript\").run(system.args);'"
}

Instance Method Summary collapse

Constructor Details

#initializeCommandLine

Run the CommandLine off the contents of ARGV.



38
39
40
41
42
43
44
45
46
47
# File 'lib/nscript/command_line.rb', line 38

def initialize
  @mtimes = {}
  parse_options
  return launch_repl if @options[:interactive]
  return eval_scriptlet if @options[:eval]
  check_sources
  return run_scripts if @options[:run]
  @sources.each {|source| compile_javascript(source) }
  watch_nscript_scripts if @options[:watch]
end

Instance Method Details

#usageObject

The “–help” usage message.



50
51
52
53
# File 'lib/nscript/command_line.rb', line 50

def usage
  puts "\n#{@option_parser}\n"
  exit
end