Class: Eye::Cli

Inherits:
Thor show all
Includes:
Commands, Render, Server
Defined in:
lib/eye/cli.rb

Defined Under Namespace

Modules: Commands, Render, Server

Instance Method Summary collapse

Instance Method Details

#break(*masks) ⇒ Object



93
94
95
# File 'lib/eye/cli.rb', line 93

def break(*masks)
  send_command(:break_chain, *masks)
end

#check(conf) ⇒ Object



111
112
113
114
115
116
117
118
# File 'lib/eye/cli.rb', line 111

def check(conf)
  conf = File.expand_path(conf) if conf && !conf.empty?

  Eye::System.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



123
124
125
126
127
128
129
130
# File 'lib/eye/cli.rb', line 123

def explain(conf)
  conf = File.expand_path(conf) if conf && !conf.empty?

  Eye::System.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



42
43
44
45
46
# File 'lib/eye/cli.rb', line 42

def history(*masks)
  res = cmd(:history_data, *masks)
  say render_history(res)
  say
end

#info(mask = nil) ⇒ Object



14
15
16
17
18
# File 'lib/eye/cli.rb', line 14

def info(mask = nil)
  res = cmd(:info_data, *Array(mask))
  say render_info(res)
  say
end

#load(*configs) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/eye/cli.rb', line 50

def load(*configs)
  configs.map!{ |c| File.expand_path(c) } if !configs.empty?

  if options[:foreground]
    # in foreground we stop another server, and run just 1 current config version
    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

#oinfoObject



35
36
37
38
39
# File 'lib/eye/cli.rb', line 35

def oinfo
  res = cmd(:short_data)
  say render_info(res)
  say
end

#quitObject



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/eye/cli.rb', line 68

def quit
  res = _cmd(:quit)

  # if eye server got crazy, stop by force
  ensure_stop_previous_server if res != :corrupted_data

  # remove pid_file
  File.delete(Eye::Local.pid_path) if File.exists?(Eye::Local.pid_path)

  say "quit...", :yellow
end

#signal(sig, *masks) ⇒ Object



88
89
90
# File 'lib/eye/cli.rb', line 88

def signal(sig, *masks)
  send_command(:signal, sig, *masks)
end

#statusObject



21
22
23
24
# File 'lib/eye/cli.rb', line 21

def status
  say ":status is deprecated, use :info instead", :yellow
  info
end

#trace(mask = "") ⇒ Object



98
99
100
# File 'lib/eye/cli.rb', line 98

def trace(mask = "")
  log_trace(mask)
end

#versionObject



104
105
106
# File 'lib/eye/cli.rb', line 104

def version
  say Eye::ABOUT
end

#watch(*args) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
# File 'lib/eye/cli.rb', line 133

def watch(*args)
  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

#xinfoObject



28
29
30
31
32
# File 'lib/eye/cli.rb', line 28

def xinfo
  res = cmd(:debug_data, :config => options[:config])
  say render_debug_info(res)
  say
end