bin/redis-browser in redis-browser-0.5.0 vs bin/redis-browser in redis-browser-0.5.1

- old
+ new

@@ -6,15 +6,17 @@ require 'optparse' require "redis-browser" # Sinatra runtime options -options = { +sinatra_options = { bind: '127.0.0.1', port: 4567 } +redis_connection = {} + OptionParser.new do |opts| opts.banner = "Usage: redis-browser [options]" opts.on("-C PATH", "--config PATH", "Path to YAML config file") do |v| require 'yaml' @@ -28,15 +30,41 @@ v = "redis://#{v}" unless v =~ /^redis:\/\// config = { 'connections' => { 'default' => v } } RedisBrowser.configure(config) end + opts.on("-h HOSTNAME", "Default redis connection hostname") do |v| + redis_connection['host'] = v + end + + opts.on("-p PORT", "Default redis connection port") do |v| + redis_connection['port'] = v + end + + opts.on("-n DB", "Default redis connection database number") do |v| + redis_connection['db'] = v + end + + opts.on("-a PASSWORD", "Default redis connection password") do |v| + redis_connection['auth'] = v + end + opts.on("-B ADDRESS", "--bind ADDRESS", "Server hostname or IP address to listen on") do |v| - options['bind'] = v + sinatra_options['bind'] = v end opts.on("-P PORT", "--port PORT", "Port number to listen on") do |v| - options['port'] = v + sinatra_options['port'] = v end + + opts.on("-v", "--version", "Display version number") do + puts RedisBrowser::VERSION + exit + end end.parse! -RedisBrowser::Web.run! options +unless redis_connection.empty? + config = { 'connections' => { 'default' => redis_connection } } + RedisBrowser.configure(config) +end + +RedisBrowser::Web.run! sinatra_options