lib/fakes3/cli.rb in fakes3-0.1.6.0 vs lib/fakes3/cli.rb in fakes3-0.1.6.1
- old
+ new
@@ -10,21 +10,23 @@
method_option :root, :type => :string, :aliases => '-r', :required => true
method_option :port, :type => :numeric, :aliases => '-p', :required => true
method_option :address, :type => :string, :aliases => '-a', :required => false, :desc => "Bind to this address. Defaults to 0.0.0.0"
method_option :hostname, :type => :string, :aliases => '-h', :desc => "The root name of the host. Defaults to s3.amazonaws.com."
method_option :limit, :aliases => '-l', :type => :string, :desc => 'Rate limit for serving (ie. 50K, 1.0M)'
+ method_option :sslcert, :type => :string, :desc => 'Path to SSL certificate'
+ method_option :sslkey, :type => :string, :desc => 'Path to SSL certificate key'
+
def server
store = nil
if options[:root]
root = File.expand_path(options[:root])
# TODO Do some sanity checking here
store = FileStore.new(root)
end
if store.nil?
- puts "You must specify a root to use a file store (the current default)"
- exit(-1)
+ abort "You must specify a root to use a file store (the current default)"
end
hostname = 's3.amazonaws.com'
if options[:hostname]
hostname = options[:hostname]
@@ -36,18 +38,23 @@
if options[:limit]
begin
store.rate_limit = options[:limit]
rescue
- puts $!.message
- exit(-1)
+ abort $!.message
end
end
address = options[:address] || '0.0.0.0'
+ ssl_cert_path = options[:sslcert]
+ ssl_key_path = options[:sslkey]
+ if (ssl_cert_path.nil? && !ssl_key_path.nil?) || (!ssl_cert_path.nil? && ssl_key_path.nil?)
+ abort "If you specify an SSL certificate you must also specify an SSL certificate key"
+ end
+
puts "Loading FakeS3 with #{root} on port #{options[:port]} with hostname #{hostname}"
- server = FakeS3::Server.new(address,options[:port],store,hostname)
+ server = FakeS3::Server.new(address,options[:port],store,hostname,ssl_cert_path,ssl_key_path)
server.serve
end
desc "version", "Report the current fakes3 version"
def version