vmc 0.4.0.beta.5 → 0.4.0.beta.6
Sign up to get free protection for your applications and to get access to all the features.
- data/{vmc-ng/LICENSE → LICENSE} +0 -0
- data/{vmc-ng/Rakefile → Rakefile} +0 -0
- data/bin/vmc +10 -11
- data/{vmc-ng/lib → lib}/vmc.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli.rb +17 -9
- data/{vmc-ng/lib → lib}/vmc/cli/app.rb +31 -31
- data/{vmc-ng/lib → lib}/vmc/cli/better_help.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/cli/command.rb +6 -6
- data/{vmc-ng/lib → lib}/vmc/cli/dots.rb +63 -8
- data/{vmc-ng/lib → lib}/vmc/cli/service.rb +6 -6
- data/{vmc-ng/lib → lib}/vmc/cli/user.rb +2 -2
- data/{vmc-ng/lib → lib}/vmc/constants.rb +1 -0
- data/{vmc-ng/lib → lib}/vmc/detect.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/errors.rb +0 -0
- data/{vmc-ng/lib → lib}/vmc/plugin.rb +0 -0
- data/lib/vmc/version.rb +3 -0
- metadata +33 -281
- data/vmc-ng/bin/vmc +0 -14
- data/vmc-ng/lib/vmc/version.rb +0 -3
- data/vmc/LICENSE +0 -24
- data/vmc/README.md +0 -102
- data/vmc/Rakefile +0 -101
- data/vmc/bin/vmc +0 -6
- data/vmc/caldecott_helper/Gemfile +0 -10
- data/vmc/caldecott_helper/Gemfile.lock +0 -48
- data/vmc/caldecott_helper/server.rb +0 -43
- data/vmc/config/clients.yml +0 -17
- data/vmc/config/micro/offline.conf +0 -2
- data/vmc/config/micro/paths.yml +0 -22
- data/vmc/config/micro/refresh_ip.rb +0 -20
- data/vmc/lib/cli.rb +0 -47
- data/vmc/lib/cli/commands/admin.rb +0 -80
- data/vmc/lib/cli/commands/apps.rb +0 -1126
- data/vmc/lib/cli/commands/base.rb +0 -227
- data/vmc/lib/cli/commands/manifest.rb +0 -56
- data/vmc/lib/cli/commands/micro.rb +0 -115
- data/vmc/lib/cli/commands/misc.rb +0 -129
- data/vmc/lib/cli/commands/services.rb +0 -180
- data/vmc/lib/cli/commands/user.rb +0 -65
- data/vmc/lib/cli/config.rb +0 -173
- data/vmc/lib/cli/console_helper.rb +0 -160
- data/vmc/lib/cli/core_ext.rb +0 -122
- data/vmc/lib/cli/errors.rb +0 -19
- data/vmc/lib/cli/frameworks.rb +0 -265
- data/vmc/lib/cli/manifest_helper.rb +0 -302
- data/vmc/lib/cli/runner.rb +0 -531
- data/vmc/lib/cli/services_helper.rb +0 -84
- data/vmc/lib/cli/tunnel_helper.rb +0 -332
- data/vmc/lib/cli/usage.rb +0 -115
- data/vmc/lib/cli/version.rb +0 -7
- data/vmc/lib/cli/zip_util.rb +0 -77
- data/vmc/lib/vmc.rb +0 -3
- data/vmc/lib/vmc/client.rb +0 -471
- data/vmc/lib/vmc/const.rb +0 -22
- data/vmc/lib/vmc/micro.rb +0 -56
- data/vmc/lib/vmc/micro/switcher/base.rb +0 -97
- data/vmc/lib/vmc/micro/switcher/darwin.rb +0 -19
- data/vmc/lib/vmc/micro/switcher/dummy.rb +0 -15
- data/vmc/lib/vmc/micro/switcher/linux.rb +0 -16
- data/vmc/lib/vmc/micro/switcher/windows.rb +0 -31
- data/vmc/lib/vmc/micro/vmrun.rb +0 -158
data/{vmc-ng/LICENSE → LICENSE}
RENAMED
File without changes
|
File without changes
|
data/bin/vmc
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# vim: ft=ruby
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
require "rubygems"
|
5
|
+
require "thor"
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
$LOAD_PATH.unshift "#{vmc_ng}/lib"
|
9
|
-
"#{vmc_ng}/bin/vmc"
|
10
|
-
else
|
11
|
-
"#{vmc}/bin/vmc"
|
12
|
-
end
|
7
|
+
require "vmc"
|
8
|
+
require "vmc/plugin"
|
13
9
|
|
14
|
-
|
15
|
-
|
10
|
+
VMC::Plugin.load_all
|
11
|
+
|
12
|
+
$exit_status = 0
|
13
|
+
VMC::CLI.start(ARGV)
|
14
|
+
exit($exit_status)
|
data/{vmc-ng/lib → lib}/vmc.rb
RENAMED
File without changes
|
@@ -56,7 +56,7 @@ module VMC
|
|
56
56
|
|
57
57
|
runtimes.each do |r|
|
58
58
|
puts ""
|
59
|
-
puts "#{c(r["name"], :
|
59
|
+
puts "#{c(r["name"], :name)}:"
|
60
60
|
puts " version: #{b(r["version"])}"
|
61
61
|
puts " description: #{b(r["description"])}"
|
62
62
|
end
|
@@ -79,7 +79,7 @@ module VMC
|
|
79
79
|
|
80
80
|
services.each do |name, meta|
|
81
81
|
puts ""
|
82
|
-
puts "#{c(name, :
|
82
|
+
puts "#{c(name, :name)}:"
|
83
83
|
puts " versions: #{meta[:versions].join ", "}"
|
84
84
|
puts " description: #{meta[:description]}"
|
85
85
|
puts " type: #{meta[:type]}"
|
@@ -134,7 +134,7 @@ module VMC
|
|
134
134
|
end
|
135
135
|
|
136
136
|
target = sane_target_url(url)
|
137
|
-
display = c(target.sub(/https?:\/\//, ""), :
|
137
|
+
display = c(target.sub(/https?:\/\//, ""), :name)
|
138
138
|
with_progress("Setting target to #{display}") do
|
139
139
|
unless force?
|
140
140
|
# check that the target is valid
|
@@ -209,7 +209,7 @@ module VMC
|
|
209
209
|
flag(:no_login, :type => :boolean)
|
210
210
|
def register(email = nil)
|
211
211
|
unless simple_output?
|
212
|
-
puts "Target: #{c(client_target, :
|
212
|
+
puts "Target: #{c(client_target, :name)}"
|
213
213
|
puts ""
|
214
214
|
end
|
215
215
|
|
@@ -282,7 +282,7 @@ module VMC
|
|
282
282
|
end
|
283
283
|
end
|
284
284
|
|
285
|
-
desc "help [COMMAND]", "
|
285
|
+
desc "help [COMMAND]", "Usage instructions"
|
286
286
|
flag :all, :default => false
|
287
287
|
group :start
|
288
288
|
def help(task = nil)
|
@@ -303,13 +303,21 @@ module VMC
|
|
303
303
|
end
|
304
304
|
end
|
305
305
|
|
306
|
+
desc "colors", "Show color configuration"
|
307
|
+
group :start, :hidden => true
|
308
|
+
def colors
|
309
|
+
user_colors.each do |n, c|
|
310
|
+
puts "#{n}: #{c(c.to_s, n)}"
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
306
314
|
private
|
307
315
|
|
308
316
|
def display_service(s)
|
309
317
|
if simple_output?
|
310
318
|
puts s.name
|
311
319
|
else
|
312
|
-
puts "#{c(s.name, :
|
320
|
+
puts "#{c(s.name, :name)}: #{s.vendor} v#{s.version}"
|
313
321
|
end
|
314
322
|
end
|
315
323
|
|
@@ -318,8 +326,8 @@ module VMC
|
|
318
326
|
puts u.email
|
319
327
|
else
|
320
328
|
puts ""
|
321
|
-
puts "#{c(u.email, :
|
322
|
-
puts " admin?: #{c(u.admin?, u.admin? ? :
|
329
|
+
puts "#{c(u.email, :name)}:"
|
330
|
+
puts " admin?: #{c(u.admin?, u.admin? ? :yes : :no)}"
|
323
331
|
end
|
324
332
|
end
|
325
333
|
|
@@ -327,7 +335,7 @@ module VMC
|
|
327
335
|
if simple_output?
|
328
336
|
puts client.target
|
329
337
|
else
|
330
|
-
puts "Target: #{c(client.target, :
|
338
|
+
puts "Target: #{c(client.target, :name)}"
|
331
339
|
end
|
332
340
|
end
|
333
341
|
end
|
@@ -134,7 +134,7 @@ module VMC
|
|
134
134
|
service.version = version
|
135
135
|
service.tier = "free"
|
136
136
|
|
137
|
-
with_progress("Creating service #{c(service_name, :
|
137
|
+
with_progress("Creating service #{c(service_name, :name)}") do
|
138
138
|
service.create!
|
139
139
|
end
|
140
140
|
|
@@ -162,7 +162,7 @@ module VMC
|
|
162
162
|
|
163
163
|
app.services = bindings
|
164
164
|
|
165
|
-
with_progress("Creating #{c(name, :
|
165
|
+
with_progress("Creating #{c(name, :name)}") do
|
166
166
|
app.create!
|
167
167
|
end
|
168
168
|
|
@@ -194,7 +194,7 @@ module VMC
|
|
194
194
|
|
195
195
|
switch_mode(app, input(:debug_mode))
|
196
196
|
|
197
|
-
with_progress("Starting #{c(name, :
|
197
|
+
with_progress("Starting #{c(name, :name)}") do |s|
|
198
198
|
if app.running?
|
199
199
|
s.skip do
|
200
200
|
err "Already started."
|
@@ -224,7 +224,7 @@ module VMC
|
|
224
224
|
fail "No applications given." if names.empty?
|
225
225
|
|
226
226
|
names.each do |name|
|
227
|
-
with_progress("Stopping #{c(name, :
|
227
|
+
with_progress("Stopping #{c(name, :name)}") do |s|
|
228
228
|
app = client.app(name)
|
229
229
|
|
230
230
|
unless app.exists?
|
@@ -265,7 +265,7 @@ module VMC
|
|
265
265
|
flag(:all, :default => false)
|
266
266
|
def delete(*names)
|
267
267
|
if input(:all)
|
268
|
-
return unless input(:really, "ALL APPS", :
|
268
|
+
return unless input(:really, "ALL APPS", :bad)
|
269
269
|
|
270
270
|
with_progress("Deleting all applications") do
|
271
271
|
client.apps.collect(&:delete!)
|
@@ -282,13 +282,13 @@ module VMC
|
|
282
282
|
end
|
283
283
|
|
284
284
|
names.each do |name|
|
285
|
-
really = input(:really, name, :
|
285
|
+
really = input(:really, name, :name)
|
286
286
|
|
287
287
|
forget(:really)
|
288
288
|
|
289
289
|
next unless really
|
290
290
|
|
291
|
-
with_progress("Deleting #{c(name, :
|
291
|
+
with_progress("Deleting #{c(name, :name)}") do
|
292
292
|
client.app(name).delete!
|
293
293
|
end
|
294
294
|
end
|
@@ -306,7 +306,7 @@ module VMC
|
|
306
306
|
|
307
307
|
names.each do |name|
|
308
308
|
instances =
|
309
|
-
with_progress("Getting instances for #{c(name, :
|
309
|
+
with_progress("Getting instances for #{c(name, :name)}") do
|
310
310
|
client.app(name).instances
|
311
311
|
end
|
312
312
|
|
@@ -342,7 +342,7 @@ module VMC
|
|
342
342
|
memory = input(:memory, app.memory)
|
343
343
|
end
|
344
344
|
|
345
|
-
with_progress("Scaling #{c(name, :
|
345
|
+
with_progress("Scaling #{c(name, :name)}") do
|
346
346
|
app.total_instances = instances.to_i if instances
|
347
347
|
app.memory = megabytes(memory) if memory
|
348
348
|
app.update!
|
@@ -376,8 +376,8 @@ module VMC
|
|
376
376
|
logs =
|
377
377
|
with_progress(
|
378
378
|
"Getting logs for " +
|
379
|
-
c(name, :
|
380
|
-
c("\##{i.index}", :
|
379
|
+
c(name, :name) + " " +
|
380
|
+
c("\##{i.index}", :instance)) do
|
381
381
|
i.files("logs")
|
382
382
|
end
|
383
383
|
|
@@ -441,7 +441,7 @@ module VMC
|
|
441
441
|
apps.each do |name, status|
|
442
442
|
unless simple_output?
|
443
443
|
puts ""
|
444
|
-
print "#{c(name, :
|
444
|
+
print "#{c(name, :name)}: "
|
445
445
|
end
|
446
446
|
|
447
447
|
puts status
|
@@ -460,7 +460,7 @@ module VMC
|
|
460
460
|
stats = info["stats"]
|
461
461
|
usage = stats["usage"]
|
462
462
|
puts ""
|
463
|
-
puts "instance #{c("#" + idx, :
|
463
|
+
puts "instance #{c("#" + idx, :name)}:"
|
464
464
|
print " cpu: #{percentage(usage["cpu"])} of"
|
465
465
|
puts " #{b(stats["cores"])} cores"
|
466
466
|
puts " memory: #{usage(usage["mem"] * 1024, stats["mem_quota"])}"
|
@@ -479,7 +479,7 @@ module VMC
|
|
479
479
|
def map(name, url)
|
480
480
|
simple = url.sub(/^https?:\/\/(.*)\/?/i, '\1')
|
481
481
|
|
482
|
-
with_progress("Updating #{c(name, :
|
482
|
+
with_progress("Updating #{c(name, :name)}") do
|
483
483
|
app = client.app(name)
|
484
484
|
app.urls << simple
|
485
485
|
app.update!
|
@@ -494,7 +494,7 @@ module VMC
|
|
494
494
|
app = client.app(name)
|
495
495
|
fail "Unknown application." unless app.exists?
|
496
496
|
|
497
|
-
with_progress("Updating #{c(name, :
|
497
|
+
with_progress("Updating #{c(name, :name)}") do |s|
|
498
498
|
unless app.urls.delete(simple)
|
499
499
|
s.fail do
|
500
500
|
err "URL #{url} is not mapped to this application."
|
@@ -523,7 +523,7 @@ module VMC
|
|
523
523
|
app = client.app(appname)
|
524
524
|
fail "Unknown application." unless app.exists?
|
525
525
|
|
526
|
-
with_progress("Updating #{c(app.name, :
|
526
|
+
with_progress("Updating #{c(app.name, :name)}") do
|
527
527
|
app.update!("env" =>
|
528
528
|
app.env.reject { |v|
|
529
529
|
v.start_with?("#{name}=")
|
@@ -537,7 +537,7 @@ module VMC
|
|
537
537
|
app = client.app(appname)
|
538
538
|
fail "Unknown application." unless app.exists?
|
539
539
|
|
540
|
-
with_progress("Updating #{c(app.name, :
|
540
|
+
with_progress("Updating #{c(app.name, :name)}") do
|
541
541
|
app.update!("env" =>
|
542
542
|
app.env.reject { |v|
|
543
543
|
v.start_with?("#{name}=")
|
@@ -566,7 +566,7 @@ module VMC
|
|
566
566
|
|
567
567
|
vars.each do |pair|
|
568
568
|
name, val = pair.split("=", 2)
|
569
|
-
puts "#{c(name, :
|
569
|
+
puts "#{c(name, :name)}: #{val}"
|
570
570
|
end
|
571
571
|
end
|
572
572
|
end
|
@@ -577,7 +577,7 @@ module VMC
|
|
577
577
|
private
|
578
578
|
|
579
579
|
def upload_app(app, path)
|
580
|
-
with_progress("Uploading #{c(app.name, :
|
580
|
+
with_progress("Uploading #{c(app.name, :name)}") do
|
581
581
|
app.upload(path)
|
582
582
|
end
|
583
583
|
end
|
@@ -597,7 +597,7 @@ module VMC
|
|
597
597
|
return true
|
598
598
|
end
|
599
599
|
|
600
|
-
with_progress("Switching mode to #{c(mode, :
|
600
|
+
with_progress("Switching mode to #{c(mode, :name)}") do |s|
|
601
601
|
runtimes = client.system_runtimes
|
602
602
|
modes = runtimes[app.runtime]["debug_modes"] || []
|
603
603
|
if modes.include?(mode)
|
@@ -616,7 +616,7 @@ module VMC
|
|
616
616
|
APP_CHECK_LIMIT = 60
|
617
617
|
|
618
618
|
def check_application(app)
|
619
|
-
with_progress("Checking #{c(app.name, :
|
619
|
+
with_progress("Checking #{c(app.name, :name)}") do |s|
|
620
620
|
if app.debug_mode == "suspend"
|
621
621
|
s.skip do
|
622
622
|
puts "Application is in suspended debugging mode."
|
@@ -642,17 +642,17 @@ module VMC
|
|
642
642
|
def state_color(s)
|
643
643
|
case s
|
644
644
|
when "STARTING"
|
645
|
-
:
|
645
|
+
:neutral
|
646
646
|
when "STARTED", "RUNNING"
|
647
|
-
:
|
647
|
+
:good
|
648
648
|
when "DOWN"
|
649
|
-
:
|
649
|
+
:bad
|
650
650
|
when "FLAPPING"
|
651
|
-
:
|
651
|
+
:error
|
652
652
|
when "N/A"
|
653
|
-
:
|
653
|
+
:unknown
|
654
654
|
else
|
655
|
-
:
|
655
|
+
:warning
|
656
656
|
end
|
657
657
|
end
|
658
658
|
|
@@ -660,7 +660,7 @@ module VMC
|
|
660
660
|
health = a.health
|
661
661
|
|
662
662
|
if a.debug_mode == "suspend" && health == "0%"
|
663
|
-
c("suspended", :
|
663
|
+
c("suspended", :neutral)
|
664
664
|
else
|
665
665
|
c(health.downcase, state_color(health))
|
666
666
|
end
|
@@ -676,7 +676,7 @@ module VMC
|
|
676
676
|
|
677
677
|
status = app_status(a)
|
678
678
|
|
679
|
-
print "#{c(a.name, :
|
679
|
+
print "#{c(a.name, :name)}: #{status}"
|
680
680
|
|
681
681
|
unless a.total_instances == 1
|
682
682
|
print ", #{b(a.total_instances)} instances"
|
@@ -694,13 +694,13 @@ module VMC
|
|
694
694
|
end
|
695
695
|
|
696
696
|
def display_instance(i)
|
697
|
-
print "instance #{c("\##{i.index}", :
|
697
|
+
print "instance #{c("\##{i.index}", :instance)}: "
|
698
698
|
puts "#{b(c(i.state.downcase, state_color(i.state)))} "
|
699
699
|
|
700
700
|
puts " started: #{c(i.since.strftime("%F %r"), :cyan)}"
|
701
701
|
|
702
702
|
if d = i.debugger
|
703
|
-
puts " debugger: port #{
|
703
|
+
puts " debugger: port #{b(d["port"])} at #{b(d["ip"])}"
|
704
704
|
end
|
705
705
|
|
706
706
|
if c = i.console
|
File without changes
|
@@ -48,7 +48,7 @@ module VMC
|
|
48
48
|
|
49
49
|
def list_choices(choices, options)
|
50
50
|
choices.each_with_index do |o, i|
|
51
|
-
puts "#{c(i + 1, :
|
51
|
+
puts "#{c(i + 1, :number)}: #{o}"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -70,7 +70,7 @@ module VMC
|
|
70
70
|
end
|
71
71
|
|
72
72
|
print "#{question}"
|
73
|
-
print c("> ", :
|
73
|
+
print c("> ", :prompt)
|
74
74
|
|
75
75
|
unless value.empty?
|
76
76
|
print "#{c(value, :black) + "\b" * value.size}"
|
@@ -288,7 +288,7 @@ module VMC
|
|
288
288
|
if script?
|
289
289
|
$stderr.puts(msg)
|
290
290
|
else
|
291
|
-
puts c(msg, :
|
291
|
+
puts c(msg, :error)
|
292
292
|
end
|
293
293
|
|
294
294
|
$exit_status = 1
|
@@ -489,11 +489,11 @@ module VMC
|
|
489
489
|
def percentage(num, low = 50, mid = 70)
|
490
490
|
color =
|
491
491
|
if num <= low
|
492
|
-
:
|
492
|
+
:good
|
493
493
|
elsif num <= mid
|
494
|
-
:
|
494
|
+
:warning
|
495
495
|
else
|
496
|
-
:
|
496
|
+
:bad
|
497
497
|
end
|
498
498
|
|
499
499
|
c(format("%.1f\%", num), color)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "rbconfig"
|
2
|
+
|
1
3
|
module VMC
|
2
4
|
module Dots
|
3
5
|
DOT_COUNT = 3
|
@@ -9,15 +11,15 @@ module VMC
|
|
9
11
|
end
|
10
12
|
|
11
13
|
def skip(&callback)
|
12
|
-
@return.call("SKIPPED", :
|
14
|
+
@return.call("SKIPPED", :warning, callback)
|
13
15
|
end
|
14
16
|
|
15
17
|
def give_up(&callback)
|
16
|
-
@return.call("GAVE UP", :
|
18
|
+
@return.call("GAVE UP", :bad, callback)
|
17
19
|
end
|
18
20
|
|
19
21
|
def fail(&callback)
|
20
|
-
@return.call("FAILED", :
|
22
|
+
@return.call("FAILED", :error, callback)
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
@@ -40,21 +42,23 @@ module VMC
|
|
40
42
|
res = yield skipper
|
41
43
|
unless simple_output?
|
42
44
|
stop_dots!
|
43
|
-
puts "... #{c("OK", :
|
45
|
+
puts "... #{c("OK", :good)}"
|
44
46
|
end
|
45
47
|
res
|
46
48
|
rescue
|
47
49
|
unless simple_output?
|
48
50
|
stop_dots!
|
49
|
-
puts "... #{c("FAILED", :
|
51
|
+
puts "... #{c("FAILED", :error)}"
|
50
52
|
end
|
51
53
|
|
52
54
|
raise
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
58
|
+
WINDOWS = !!(RbConfig::CONFIG['host_os'] =~ /mingw|mswin32|cygwin/)
|
59
|
+
|
56
60
|
def color?
|
57
|
-
$stdout.tty?
|
61
|
+
!WINDOWS && $stdout.tty?
|
58
62
|
end
|
59
63
|
|
60
64
|
COLOR_CODES = {
|
@@ -68,13 +72,64 @@ module VMC
|
|
68
72
|
:white => 7
|
69
73
|
}
|
70
74
|
|
75
|
+
DEFAULT_COLORS = {
|
76
|
+
:name => :blue,
|
77
|
+
:neutral => :blue,
|
78
|
+
:good => :green,
|
79
|
+
:bad => :red,
|
80
|
+
:error => :magenta,
|
81
|
+
:unknown => :cyan,
|
82
|
+
:warning => :yellow,
|
83
|
+
:instance => :yellow,
|
84
|
+
:number => :green,
|
85
|
+
:prompt => :blue,
|
86
|
+
:yes => :green,
|
87
|
+
:no => :red
|
88
|
+
}
|
89
|
+
|
90
|
+
def user_colors
|
91
|
+
return @user_colors if @user_colors
|
92
|
+
|
93
|
+
colors = File.expand_path VMC::COLORS_FILE
|
94
|
+
|
95
|
+
if File.exists? colors
|
96
|
+
@user_colors = DEFAULT_COLORS.dup
|
97
|
+
|
98
|
+
YAML.load_file(colors).each do |k, v|
|
99
|
+
if k == true
|
100
|
+
k = :yes
|
101
|
+
elsif k == false
|
102
|
+
k = :no
|
103
|
+
else
|
104
|
+
k = k.to_sym
|
105
|
+
end
|
106
|
+
|
107
|
+
@user_colors[k] = v.to_sym
|
108
|
+
end
|
109
|
+
|
110
|
+
@user_colors
|
111
|
+
else
|
112
|
+
@user_colors = DEFAULT_COLORS
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
71
116
|
# colored text
|
72
117
|
#
|
73
118
|
# shouldn't use bright colors, as some color themes abuse
|
74
119
|
# the bright palette (I'm looking at you, Solarized)
|
75
|
-
def c(str,
|
120
|
+
def c(str, type)
|
76
121
|
return str unless color?
|
77
|
-
|
122
|
+
|
123
|
+
bright = false
|
124
|
+
color = user_colors[type]
|
125
|
+
if color =~ /bright-(.+)/
|
126
|
+
bright = true
|
127
|
+
color = $1.to_sym
|
128
|
+
end
|
129
|
+
|
130
|
+
return str unless color
|
131
|
+
|
132
|
+
"\e[#{bright ? 9 : 3}#{COLOR_CODES[color]}m#{str}\e[0m"
|
78
133
|
end
|
79
134
|
module_function :c
|
80
135
|
|