Sha256: 4cf523f350be34955618f56f41c16547c628928247ce850c8ba4bd5c92d48af6

Contents?: true

Size: 1.82 KB

Versions: 8

Compression:

Stored size: 1.82 KB

Contents

#!/usr/bin/env ruby

$:.unshift File.dirname(__FILE__) + "/../lib"

require 'optparse'
require 'rubygems'
require 'less'

begin
  require 'growl'
rescue LoadError
  Less::GROWL = false
else
  Less::GROWL = true
end

# Argument defaults
options = {
  :watch => false,
  :compress => false,
  :debug => false,
  :growl => false,
  :color => true
}

# Get arguments
opts = OptionParser.new do |o|
  o.banner = "usage: lessc source [destination] [--watch]"
  o.separator ""
  
  # Watch mode
  o.on("-w", "--watch", "watch for changes") do
    options[:watch] = true
  end
  
  # Growl
  o.on("-g", "--growl", "growl notifications") do
    if Less::GROWL && (Growl.installed? rescue false)
      options[:growl] = true
    elsif Less::GROWL
      abort "Growl or 'growlnotify' wasn't found on your system."
    else
      abort "Growl gem not found, please install with: " +
            "`sudo gem install visionmedia-growl -s http://gems.github.com`"
    end
  end
  
  # No color in output
  o.on("--no-color", "suppress color in output") do
    options[:color] = false
  end
  
  # Compression needs a proper algorithm
  #
  #  o.on("-x", "--compress", "compress css file") do
  #    options[:compress] = true
  #  end
  
  o.separator ""

  # Help
  o.on_tail("-h", "--help", "show this message") do
    puts opts
    exit
  end
  
  o.on_tail("-d", "--debug", "show full error messages") do
    options[:debug] = true
  end

  # Version
  o.on_tail("-v", "--version", "show version") do
    puts "lessc " + Less.version
    exit
  end
end

opts.parse! # Parse arguments into `options` hash

# Get source and destintation from command line
case ARGV.size
  when 1
    options[:source] = ARGV[ 0 ]
  when 2
    options[:source] = ARGV[ 0 ]
    options[:destination] = ARGV[ 1 ]
  else
    puts opts
    exit
end

Less::Command.new( options ).run! ? exit(0) : exit(1)

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
cloudhead-less-1.2.4 bin/lessc
cloudhead-less-1.2.5 bin/lessc
cloudhead-less-1.2.7 bin/lessc
cloudhead-less-1.2.8 bin/lessc
unboxed-less-1.2.12 bin/lessc
less-1.2.11 bin/lessc
less-1.2.10 bin/lessc
less-1.2.9 bin/lessc