Sha256: 1ea52ab0e9f1e1f6c101fa8debcb76fa89d607e57229e3dc314cd82a56126563
Contents?: true
Size: 1.45 KB
Versions: 38
Compression:
Stored size: 1.45 KB
Contents
module LitmusPaper module CLI class Admin def self.commands { "list" => LitmusPaper::CLI::Admin::List, "force" => LitmusPaper::CLI::Admin::Force, "status" => LitmusPaper::CLI::Admin::Status } end 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 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 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 end end end
Version data entries
38 entries across 38 versions & 1 rubygems