Class: Pedant::Command
- Inherits:
-
Object
show all
- Defined in:
- lib/pedant/command.rb
Class Method Summary
collapse
Class Method Details
.all ⇒ Object
33
34
35
|
# File 'lib/pedant/command.rb', line 33
def self.all
(@_all ||= [])
end
|
.banner(title, width = 80) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/pedant/command.rb', line 53
def self.banner(title, width=80)
middle = "[ #{title} ]"
width = width.to_f
leftover = (width - middle.length) / 2
left = '-' * leftover.floor
right = '-' * leftover.ceil
left + middle + right
end
|
.find(cmd) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/pedant/command.rb', line 45
def self.find(cmd)
all.each do |cls|
return cls if cls.binding == cmd
end
nil
end
|
.inherited(cls) ⇒ Object
37
38
39
|
# File 'lib/pedant/command.rb', line 37
def self.inherited(cls)
all << cls
end
|
.initialize! ⇒ Object
29
30
31
|
# File 'lib/pedant/command.rb', line 29
def self.initialize!
Dir.glob(Pedant.lib + 'pedant/commands/*.rb').each {|f| load(f)}
end
|
.list ⇒ Object
41
42
43
|
# File 'lib/pedant/command.rb', line 41
def self.list
all.map{ |cls| cls.binding }.sort
end
|
.run(opts, args) ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/pedant/command.rb', line 68
def self.run(opts, args)
opts, args = optparse(opts, args)
self.run_all(opts, args)
end
|
.usage(msg) ⇒ Object
76
77
78
79
80
81
|
# File 'lib/pedant/command.rb', line 76
def self.usage(msg)
puts Rainbow(msg).color(:red)
puts
puts help
exit 1
end
|