Sha256: a2673fb84ba73b6d194042c407db804005b48089c15d3016498bd5eb3dd872ed
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.2' 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.2 | bin/ddbcli |