lib/ddbcli/cli/options.rb in ddbcli-0.3.0 vs lib/ddbcli/cli/options.rb in ddbcli-0.3.1
- old
+ new
@@ -5,11 +5,11 @@
def parse_options
options = OpenStruct.new
options.access_key_id = ENV['AWS_ACCESS_KEY_ID']
options.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
options.ddb_endpoint_or_region =
- ENV['DDB_ENDPOINT'] || ENV['DDB_REGION'] || 'dynamodb.us-east-1.amazonaws.com'
+ ENV['AWS_REGION'] || ENV['DDB_ENDPOINT'] || ENV['DDB_REGION'] || 'dynamodb.us-east-1.amazonaws.com'
# default value
options.timeout = 60
options.consistent = false
options.iteratable = false
@@ -20,16 +20,19 @@
ARGV.options do |opt|
opt.on('-k', '--access-key=ACCESS_KEY') {|v| options.access_key_id = v }
opt.on('-s', '--secret-key=SECRET_KEY') {|v| options.secret_access_key = v }
opt.on('-r', '--region=REGION_OR_ENDPOINT') {|v| options.ddb_endpoint_or_region = v }
- opt.on('', '--uri=URI') {|v|
+ url_opt = proc do |v|
uri = v
uri = "http://#{uri}" unless uri =~ %r|\A\w+://|
uri = URI.parse(uri)
raise URI::InvalidURIError, "invalid shceme: #{v}" unless /\Ahttps?\Z/ =~ uri.scheme
options.ddb_endpoint_or_region = uri
- }
+ end
+
+ opt.on('', '--url=URL', &url_opt)
+ opt.on('', '--uri=URL (DEPRECATION)', &url_opt)
opt.on('-e', '--eval=COMMAND') {|v| options.command = v }
opt.on('-t', '--timeout=SECOND', Integer) {|v| options.timeout = v.to_i }
opt.on('', '--import=TABLE,JSON_FILE') {|v|