From 46ccb5b6e1344ad1aa3b78ecf5b7e19d576d42eb Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sat, 14 Nov 2009 10:11:19 -0800 Subject: [PATCH] [Command Line] Access the Sass Repl (sass -i) with the compass environment loaded. --- lib/compass/commands.rb | 2 +- lib/compass/commands/interactive.rb | 61 +++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 lib/compass/commands/interactive.rb diff --git a/lib/compass/commands.rb b/lib/compass/commands.rb index 7389a508..ce22e296 100644 --- a/lib/compass/commands.rb +++ b/lib/compass/commands.rb @@ -6,6 +6,6 @@ require 'compass/commands/registry' %w(base generate_grid_background help list_frameworks project_base update_project watch_project create_project installer_command print_version project_stats stamp_pattern validate_project - write_configuration).each do |lib| + write_configuration interactive).each do |lib| require "compass/commands/#{lib}" end diff --git a/lib/compass/commands/interactive.rb b/lib/compass/commands/interactive.rb new file mode 100644 index 00000000..c0a0d46f --- /dev/null +++ b/lib/compass/commands/interactive.rb @@ -0,0 +1,61 @@ + +require 'compass/commands/project_base' +require 'compass/commands/update_project' + +module Compass + module Commands + module InteractiveOptionsParser + def set_options(opts) + opts.banner = %Q{ + Usage: compass interactive [path/to/project] [options] + + Description: + Interactively evaluate SassScript + + Options: + }.strip.split("\n").map{|l| l.gsub(/^ {0,10}/,'')}.join("\n") + + super + end + end + class Interactive < ProjectBase + + register :interactive + + def initialize(working_path, options) + super + end + + def perform + require 'sass/repl' + Sass::Repl.new.run + end + + class << self + + def option_parser(arguments) + parser = Compass::Exec::CommandOptionParser.new(arguments) + parser.extend(Compass::Exec::GlobalOptionsParser) + parser.extend(Compass::Exec::ProjectOptionsParser) + parser.extend(InteractiveOptionsParser) + end + + def usage + option_parser([]).to_s + end + + def description(command) + "Interactively evaluate SassScript" + end + + def parse!(arguments) + parser = option_parser(arguments) + parser.parse! + parser.options + end + + end + + end + end +end