forked from livingsocial/ganapati
/
hls
executable file
·42 lines (35 loc) · 961 Bytes
/
hls
1
2
3
4
5
6
7
8
9
10
11
12
13
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
#!/usr/bin/env ruby
require 'optparse'
require 'rubygems'
require 'ganapati'
VERBOSE_PROPS = [:path, :length, :isdir, :modification_time, :permission, :owner, :group]
options = { :verbose => false, :recursive => false }
op = OptionParser.new { |opts|
opts.banner = "Usage: hls [options] host:port/location"
opts.on('-h', '--help', 'displays usage information') {
puts opts
exit
}
opts.on('-r', '--recursive', 'copy recursively') {
options[:recursive] = true
}
opts.on('-v', '--verbose', 'verbose output') {
puts VERBOSE_PROPS.map { |a| a.to_s }.join("\t")
options[:verbose] = true
}
}
op.parse!
if ARGV.length != 1
puts op.to_s
exit 1
end
url = Ganapati::FileUrl.new ARGV.first
client = Ganapati::Client.new url.host, url.port
client.ls(url.path, options[:verbose], options[:recursive]).each { |s|
if options[:verbose]
puts VERBOSE_PROPS.map { |p| s.send p }.join("\t")
else
puts s
end
}
client.close