Sha256: ce1d602913296f03c196ee862a73e2f9c7250d01f8bc41b9237bc33bcb1a1b4e
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
require 'thor' require 'fakes3/server' require 'fakes3/version' module FakeS3 class CLI < Thor default_task("server") desc "server", "Run a server on a particular hostname" method_option :root, :type => :string, :aliases => '-r', :required => true method_option :port, :type => :numeric, :aliases => '-p', :required => true 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)' def server store = nil if options[:root] root = File.expand_path(options[:root]) store = FileStore.new(root) end if store.nil? puts "You must specify a root to use a file store (the current default)" exit(-1) end hostname = 's3.amazonaws.com' if options[:hostname] hostname = options[:hostname] # In case the user has put a port on the hostname if hostname =~ /:(\d+)/ hostname = hostname.split(":")[0] end end if options[:limit] begin store.rate_limit = options[:limit] rescue puts $!.message exit(-1) end end puts "Loading FakeS3 with #{root} on port #{options[:port]} with hostname #{hostname}" server = FakeS3::Server.new(options[:port],store,hostname) server.serve end desc "version", "Report the current fakes3 version" def version puts <<"EOF" ====================== FakeS3 #{FakeS3::VERSION} Copyright 2012, Curtis Spencer (@jubos) EOF end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fakes3-0.1.1 | lib/fakes3/cli.rb |
fakes3-0.1.0 | lib/fakes3/cli.rb |