Sha256: 8dab4251b897a61e2b16944220c6c3a44a2a48078f7ba9387771c21ce1ec2e87
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
#!/usr/bin/env ruby $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib') Version = '0.1.1' require 'rubygems' require 'ddbcli' require 'readline' options = parse_options driver = DynamoDB::Driver.new( options.access_key_id, options.secret_access_key, options.ddb_endpoint_or_region) driver.timeout = options.timeout driver.consistent = !!options.consistent driver.retry_num = options.retry_num driver.retry_intvl = options.retry_intvl driver.debug = options.debug if not $stdin.tty? or options.command # run mode src = options.command || $stdin.read.strip # complements separator unless src =~ /\s*(?:;|\\G)\s*\Z/i src << ';' end begin evaluate_query(driver, src) rescue => e print_error(e.message) print_error(e.backtrace) if driver.debug exit 1 end else # interactive mode src = '' prompt1 = lambda { "#{driver.region || 'unknown'}> " } prompt2 = lambda { "#{' ' * (prompt1.call.length - 3)}-> " } while buf = Readline.readline((src.empty? ? prompt1.call : prompt2.call), true) # ignore blank lines if /\A\s*\Z/ =~ buf Readline::HISTORY.pop next end if src.empty? and buf =~ /\A\.(.+)/ evaluate_command(driver, $1) else begin src << (src.empty? ? buf : ("\n" + buf)) evaluate_query(driver, src, :show_rows => true) rescue => e print_error(e.message) print_error(e.backtrace) if driver.debug end prompt = src.empty? ? prompt1.call : prompt2.call end end # end of while end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ddbcli-0.1.1 | bin/ddbcli |