sdbcli 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +29 -22
  2. data/bin/sdbcli +28 -13
  3. data/lib/sdbcli/sdb-runner.rb +10 -2
  4. metadata +5 -5
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == Description
4
4
 
5
- sdbcli is command line client of Amazon SimpleDB.
5
+ sdbcli is interactive command-line client of Amazon SimpleDB.
6
6
 
7
7
  == Source Code
8
8
 
@@ -19,30 +19,37 @@ https://bitbucket.org/winebarrel/sdbcli
19
19
  == Example
20
20
 
21
21
  ap-northeast-1> help
22
- commands:
23
- show domains
24
- create domain domain_name
25
- drop domain domain_name
26
- get [output_list] from domain_name where itemname = '...'
27
- insert into domain_name (itemname, attr1, attr2, ...) values ('name', 'val1', 'val2', ...)
28
- update domain_name set attr1 = 'val1', attr2 = 'val2', ... where itemname = '...'
29
- delete [attr1, attr2, ...] from domain_name itemname = '...'
30
- select output_list from domain_name [where expression] [sort_instructions] [limit limit]
22
+ SHOW domains
23
+ displays a domain list
24
+
25
+ CREATE domain domain_name
26
+ creates a domain
27
+
28
+ DROP DOMAIN domain_name
29
+ deletes a domain
30
+
31
+ GET [output_list] FROM domain_name WHERE itemName = '...'
32
+ gets the attribute of an item
33
+
34
+ INSERT INTO domain_name (itemName, attr1, ...) values ('name', 'val1', ...)
35
+ creates an item
36
+
37
+ UPDATE domain_name set attr1 = 'val1', ... where itemName = '...'
38
+ updates an item
39
+
40
+ DELETE [attr1, ...] FROM domain_name itemName = '...'
41
+ deletes the attribute of an item or an item
42
+
43
+ SELECT output_list FROM domain_name [where expression] [sort_instructions] [limit limit]
44
+ queries using the SELECT statement
45
+
31
46
  ap-northeast-1> select * from test
32
47
  ---
33
- - - itemname1
34
- - attr1: val1
35
- attr2: val2
36
- - - itemname2
37
- - attr1: val1
38
- attr2: val2
48
+ - [itemname1, {attr1: val1, attr2: val2}]
49
+ - [itemname2, {attr1: val1, attr2: val2}]
39
50
 
40
51
  shell> echo 'select * from test' | sdbcli
41
52
  ---
42
- - - itemname1
43
- - attr1: val1
44
- attr2: val2
45
- - - itemname2
46
- - attr1: val1
47
- attr2: val2
53
+ - [itemname1, {attr1: val1, attr2: val2}]
54
+ - [itemname2, {attr1: val1, attr2: val2}]
48
55
 
data/bin/sdbcli CHANGED
@@ -13,9 +13,9 @@ secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
13
13
  sdb_endpoint = ENV['SDB_ENDPOINT'] || 'sdb.amazonaws.com'
14
14
 
15
15
  ARGV.options do |opt|
16
- opt.on('-k', '--access-key-id=AWS_ACCESS_KEY_ID') {|v| access_key_id = v }
17
- opt.on('-s', '--secret-access-key=AWS_SECRET_ACCESS_KEY') {|v| secret_access_key = v }
18
- opt.on('-e', '--endpoint=SDB_ENDPOINT') {|v| sdb_endpoint = v }
16
+ opt.on('-k', '--access-key=ACCESS_KEY') {|v| access_key_id = v }
17
+ opt.on('-s', '--secret-key=SECRET_KEY') {|v| secret_access_key = v }
18
+ opt.on('-e', '--endpoint=ENDPOINT') {|v| sdb_endpoint = v }
19
19
  opt.parse!
20
20
 
21
21
  unless access_key_id and secret_access_key and sdb_endpoint
@@ -44,15 +44,30 @@ end
44
44
 
45
45
  def help
46
46
  <<-EOS
47
- commands:
48
- show domains
49
- create domain domain_name
50
- drop domain domain_name
51
- get [output_list] from domain_name where itemname = '...'
52
- insert into domain_name (itemname, attr1, attr2, ...) values ('name', 'val1', 'val2', ...)
53
- update domain_name set attr1 = 'val1', attr2 = 'val2', ... where itemname = '...'
54
- delete [attr1, attr2, ...] from domain_name itemname = '...'
55
- select output_list from domain_name [where expression] [sort_instructions] [limit limit]
47
+ SHOW domains
48
+ displays a domain list
49
+
50
+ CREATE domain domain_name
51
+ creates a domain
52
+
53
+ DROP DOMAIN domain_name
54
+ deletes a domain
55
+
56
+ GET [output_list] FROM domain_name WHERE itemName = '...'
57
+ gets the attribute of an item
58
+
59
+ INSERT INTO domain_name (itemName, attr1, ...) values ('name', 'val1', ...)
60
+ creates an item
61
+
62
+ UPDATE domain_name set attr1 = 'val1', ... where itemName = '...'
63
+ updates an item
64
+
65
+ DELETE [attr1, ...] FROM domain_name itemName = '...'
66
+ deletes the attribute of an item or an item
67
+
68
+ SELECT output_list FROM domain_name [where expression] [sort_instructions] [limit limit]
69
+ queries using the SELECT statement
70
+
56
71
  EOS
57
72
  end
58
73
 
@@ -67,6 +82,6 @@ while buf = Readline.readline("#{region}> ", true)
67
82
  execute(buf.sub(/;\Z/, ''))
68
83
  end
69
84
  rescue => e
70
- puts e.message
85
+ puts e.message.strip
71
86
  end
72
87
  end
@@ -23,7 +23,9 @@ module SimpleDB
23
23
 
24
24
  case command
25
25
  when :GET
26
- @driver.get(parsed.domain, parsed.item_name, parsed.attr_names)
26
+ item = @driver.get(parsed.domain, parsed.item_name, parsed.attr_names)
27
+ def item.to_yaml_style; :inline; end
28
+ item
27
29
  when :INSERT
28
30
  @driver.insert(parsed.domain, parsed.item_name, parsed.attrs)
29
31
  nil
@@ -34,7 +36,13 @@ module SimpleDB
34
36
  @driver.delete(parsed.domain, parsed.items)
35
37
  nil
36
38
  when :SELECT
37
- @driver.select(parsed.query)
39
+ items = @driver.select(parsed.query)
40
+
41
+ items.each do |item|
42
+ def item.to_yaml_style; :inline; end
43
+ end
44
+
45
+ items
38
46
  when :CREATE
39
47
  @driver.create_domain(parsed.domain)
40
48
  nil
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdbcli
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - winebarrel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-16 00:00:00 Z
18
+ date: 2012-01-17 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: nokogiri
@@ -80,6 +80,6 @@ rubyforge_project:
80
80
  rubygems_version: 1.8.11
81
81
  signing_key:
82
82
  specification_version: 3
83
- summary: sdbcli is command line client of Amazon SimpleDB.
83
+ summary: sdbcli is interactive command-line client of Amazon SimpleDB.
84
84
  test_files: []
85
85