Class: Eye::Cli
Defined Under Namespace
Modules: Commands, Render, Server
Instance Method Summary
collapse
Instance Method Details
#break(*masks) ⇒ Object
144
145
146
|
# File 'lib/eye/cli.rb', line 144
def break(*masks)
send_command(:break_chain, *masks)
end
|
#check(conf) ⇒ Object
162
163
164
165
166
167
168
169
|
# File 'lib/eye/cli.rb', line 162
def check(conf)
conf = File.expand_path(conf) if conf && !conf.empty?
Eye::Local.host = options[:host] if options[:host]
Eye::Dsl.verbose = options[:verbose]
say_load_result Eye::Controller.new.check(conf), syntax: true
end
|
#explain(conf) ⇒ Object
174
175
176
177
178
179
180
181
|
# File 'lib/eye/cli.rb', line 174
def explain(conf)
conf = File.expand_path(conf) if conf && !conf.empty?
Eye::Local.host = options[:host] if options[:host]
Eye::Dsl.verbose = options[:verbose]
say_load_result Eye::Controller.new.explain(conf), print_config: true, syntax: true
end
|
#force_restart(*masks) ⇒ Object
133
134
135
136
|
# File 'lib/eye/cli.rb', line 133
def force_restart(*masks)
send_command(:stop, *masks)
send_command(:start, *masks)
end
|
#history(*masks) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/eye/cli.rb', line 71
def history(*masks)
res = cmd(:history_data, *masks)
if !masks.empty? && res && res.empty?
error!('command :history, objects not found!')
end
if options[:json]
say_json(res)
else
say render_history(res)
say
end
end
|
#info(mask = nil) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/eye/cli.rb', line 19
def info(mask = nil)
h = {}
h[:procline] = true if options[:procline]
res = cmd(:info_data, *Array(mask), h)
if mask && res[:subtree] && res[:subtree].empty?
error!('command :info, objects not found!')
end
if options[:json]
say_json(res)
else
say render_info(res)
say
end
end
|
#load(*configs) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/eye/cli.rb', line 86
def load(*configs)
configs.map! { |c| File.expand_path(c) }
if options[:foreground]
error!('foreground expected only one config') if configs.size > 1
server_start_foreground(configs.first)
elsif server_started?
configs << Eye::Local.eyefile if Eye::Local.local_runner && configs.empty? && Eye::Local.eyefile
say_load_result cmd(:load, *configs)
else
server_start(configs)
end
end
|
#oinfo(mask = nil) ⇒ Object
59
60
61
62
63
64
65
66
67
|
# File 'lib/eye/cli.rb', line 59
def oinfo(mask = nil)
res = cmd(:short_data, *Array(mask))
if options[:json]
say_json(res)
else
say render_info(res)
say
end
end
|
#signal(sig, *masks) ⇒ Object
139
140
141
|
# File 'lib/eye/cli.rb', line 139
def signal(sig, *masks)
send_command(:signal, sig, *masks)
end
|
#status(name) ⇒ Object
37
38
39
40
41
42
|
# File 'lib/eye/cli.rb', line 37
def status(name)
res = cmd(:info_data, *Array(name))
es, msg = render_status(res)
say(msg, :red) if msg && !msg.empty?
exit(es)
end
|
#trace(mask = '') ⇒ Object
149
150
151
|
# File 'lib/eye/cli.rb', line 149
def trace(mask = '')
log_trace(mask)
end
|
#user_command(cmd, *args) ⇒ Object
202
203
204
|
# File 'lib/eye/cli.rb', line 202
def user_command(cmd, *args)
send_command(:user_command, cmd, *args)
end
|
155
156
157
|
# File 'lib/eye/cli.rb', line 155
def version
say Eye::ABOUT
end
|
#watch(*args) ⇒ Object
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
# File 'lib/eye/cli.rb', line 185
def watch(*args)
error!('You should install watch utility') if `which watch`.empty?
cmd = if `watch --version 2>&1`.chop > '0.2.0'
"watch -n 1 --color #{$0} i #{args * ' '}"
else
"watch -n 1 #{$0} i #{args * ' '}"
end
cmd += ' -p' if options[:procline]
pid = Process.spawn(cmd)
Process.waitpid(pid)
rescue Interrupt
end
|
47
48
49
50
51
52
53
54
55
|
# File 'lib/eye/cli.rb', line 47
def xinfo
res = cmd(:debug_data, config: options[:config])
if options[:json]
say_json(res)
else
say render_debug_info(res)
say
end
end
|