Class: Shuck::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/shuck/cli.rb

Instance Method Summary collapse

Instance Method Details

#serverObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/shuck/cli.rb', line 14

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 Shuck with #{root} on port #{options[:port]} with hostname #{hostname}"
  server = Shuck::Server.new(options[:port],store,hostname)
  server.serve
end

#versionObject



50
51
52
53
54
55
56
57
# File 'lib/shuck/cli.rb', line 50

def version
  puts <<"EOF"
======================
Shuck #{Shuck::VERSION}

Copyright 2012, Curtis Spencer (@jubos)
EOF
end