Module: MLS::CLI
- Defined in:
- lib/mls/cli.rb
Defined Under Namespace
Modules: Documents, Storage
Class Method Summary
collapse
Class Method Details
.options ⇒ Object
7
8
9
10
11
12
|
# File 'lib/mls/cli.rb', line 7
def self.options
if !class_variable_defined?(:@@options)
@@options = {}
end
@@options
end
|
.parse_args(args) ⇒ Object
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
|
# File 'lib/mls/cli.rb', line 14
def self.parse_args(args)
OptionParser.new do |opts|
opts.on("-aURL", "--auth=URL", "URL Credentials for MLS, S3 or B2") do |arg|
url = URI.parse(arg)
case url.scheme
when 's3' MLS::CLI.options[:s3] = {
access_key_id: URI.unescape(url.user),
secret_access_key: URI.unescape(url.password),
bucket: URI.unescape(url.host)
}
MLS::CLI.options[:s3][:prefix] = url.path if url.path && !url.path.empty?
url.query.split('&').each do |qp|
key, value = qp.split('=').map { |d| URI.unescape(d) }
case key
when 'partition'
MLS::CLI.options[:s3][:partition] = true
MLS::CLI.options[:s3][:partition_depth] = value.to_i
end
end
when 'b2'
when 'mls'
arg = arg.sub('mls://', 'https://')
MLS::CLI.options[:mls] = arg
MLS::Model.establish_connection(adapter: 'sunstone', url: arg)
end
end
end.parse!(args)
end
|