This repository was archived by the owner on Dec 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathlessc
executable file
·102 lines (84 loc) · 2.06 KB
/
lessc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/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,
:timestamps => false,
:color => $stdout.tty?
}
# 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
# Timestamps
o.on("-t", "--timestamps", "show timestamps in watch mode") do
options[:timestamps] = true
end
# No color in output
o.on("--no-color", "suppress color in output") do
options[:color] = false
end
o.on('--verbose', 'show success messages when using growl') do
options[:verbose] = true
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)