Class: LitmusPaper::CLI::Admin
- Inherits:
-
Object
- Object
- LitmusPaper::CLI::Admin
show all
- Defined in:
- lib/litmus_paper/cli/admin.rb,
lib/litmus_paper/cli/admin/list.rb,
lib/litmus_paper/cli/admin/force.rb,
lib/litmus_paper/cli/admin/status.rb,
lib/litmus_paper/cli/admin/command.rb
Defined Under Namespace
Classes: Command, Force, List, Status
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Method Details
#_display_help ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/litmus_paper/cli/admin.rb', line 25
def _display_help
puts "Litmus Paper CLI v#{LitmusPaper::VERSION}\n\n"
puts "Commands:\n"
Admin.commands.keys.sort.each do |name|
puts " %-8s %s" % [name, Admin.commands[name].description]
end
puts "\nSee 'litmusctl <command> --help' for more information on a specific command"
end
|
#_litmus_request(host, port, request) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/litmus_paper/cli/admin.rb', line 34
def _litmus_request(host, port, request)
begin
http = Net::HTTP.start(host, port)
response = http.request(request)
puts response.body
case response
when Net::HTTPSuccess then exit 0
when Net::HTTPClientError then exit 2
else exit 1
end
rescue Errno::ECONNREFUSED => e
puts "Unable to connect to litmus on #{host}:#{port}: #{e.message}"
exit 1
end
end
|
#run(argv = ARGV) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/litmus_paper/cli/admin.rb', line 12
def run(argv = ARGV)
command_name = argv.shift
if command = Admin.commands[command_name]
options = {}
request = command.build_request(options, argv)
LitmusPaper.configure(options[:litmus_config])
_litmus_request('127.0.0.1', LitmusPaper.port, request)
else
_display_help
end
end
|