Class: StyleScript::CommandLine

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

Overview

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

Constant Summary collapse

"style compiles StyleScript source files into JavaScript.\n\nUsage:\n  style path/to/script.style\n"
WATCH_INTERVAL =

Seconds to pause between checks for changed source files.

0.5
ROOT =

Path to the root of the StyleScript install.

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

Commands to execute StyleScripts.

{
  :node     => "node #{ROOT}/lib/style_script/runner.js",
  :std  => "std -p #{ROOT} -e 'require(\"style-script\").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/style_script/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_style_scripts if @options[:watch]
end

Instance Method Details

#usageObject

The “–help” usage message.



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

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