Class: Eye::Cli
Defined Under Namespace
Modules: Commands, Render, Server
Instance Method Summary
collapse
Instance Method Details
#break(*masks) ⇒ Object
118
119
120
|
# File 'lib/eye/cli.rb', line 118
def break(*masks)
send_command(:break_chain, *masks)
end
|
#check(conf) ⇒ Object
136
137
138
139
140
141
142
143
|
# File 'lib/eye/cli.rb', line 136
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
148
149
150
151
152
153
154
155
|
# File 'lib/eye/cli.rb', line 148
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
|
#history(*masks) ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/eye/cli.rb', line 56
def history(*masks)
res = cmd(:history_data, *masks)
if !masks.empty? && res && res.empty?
error!("command :history, objects not found!")
end
say render_history(res)
say
end
|
#info(mask = nil) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/eye/cli.rb', line 17
def info(mask = nil)
res = cmd(:info_data, *Array(mask))
if mask && res[:subtree] && res[:subtree].empty?
error!("command :info, objects not found!")
end
if options[:json]
require 'json'
say JSON.dump(res)
else
say render_info(res)
say
end
end
|
#load(*configs) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/eye/cli.rb', line 67
def load(*configs)
configs.map!{ |c| File.expand_path(c) } if !configs.empty?
if options[:foreground]
error!("foreground expected only one config") if configs.size > 1
server_start_foreground(configs.first)
elsif server_started?
say_load_result cmd(:load, *configs)
else
server_start(configs)
end
end
|
#oinfo(mask = nil) ⇒ Object
49
50
51
52
53
|
# File 'lib/eye/cli.rb', line 49
def oinfo(mask = nil)
res = cmd(:short_data, *Array(mask))
say render_info(res)
say
end
|
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/eye/cli.rb', line 87
def quit
if options[:stop_all]
Eye::Local.client_timeout = options[:timeout].to_i
cmd(:stop_all, options[:timeout].to_i)
end
Eye::Local.client_timeout = 5
res = _cmd(:quit)
ensure_stop_previous_server if res != :corrupted_data
File.delete(Eye::Local.pid_path) if File.exists?(Eye::Local.pid_path)
say "Quit ಠ╭╮ಠ", :yellow
end
|
#signal(sig, *masks) ⇒ Object
113
114
115
|
# File 'lib/eye/cli.rb', line 113
def signal(sig, *masks)
send_command(:signal, sig, *masks)
end
|
#status(name) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/eye/cli.rb', line 33
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
123
124
125
|
# File 'lib/eye/cli.rb', line 123
def trace(mask = "")
log_trace(mask)
end
|
#user_command(cmd, *args) ⇒ Object
173
174
175
|
# File 'lib/eye/cli.rb', line 173
def user_command(cmd, *args)
send_command(:user_command, cmd, *args)
end
|
129
130
131
|
# File 'lib/eye/cli.rb', line 129
def version
say Eye::ABOUT
end
|
#watch(*args) ⇒ Object
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# File 'lib/eye/cli.rb', line 158
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
pid = Process.spawn(cmd)
Process.waitpid(pid)
rescue Interrupt
end
|
42
43
44
45
46
|
# File 'lib/eye/cli.rb', line 42
def xinfo
res = cmd(:debug_data, :config => options[:config])
say render_debug_info(res)
say
end
|