ec2ctl 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ec2ctl/version.rb +1 -1
  3. data/lib/ec2ctl.rb +15 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bea0a185379f61297a427c2c7efc2af67df6b763
4
- data.tar.gz: 6135a1d00da6cbb6df57a8f184d24dc8d87104d3
3
+ metadata.gz: 319f5a1aefbfb891cef4f93652d1f77c3daaaf53
4
+ data.tar.gz: 94d9ddfa009434ecdf7ce25af21dcd13639280df
5
5
  SHA512:
6
- metadata.gz: 8729284c92f26b5220aab5925715b3056696a3a03fd116254dd8920e2d3d548baa0f1b5595b185fc3b3b4b11c63ef04979f044171c3bff3c6a97e3313e839949
7
- data.tar.gz: e4451be5017a641a415e2f5da2e8463ac2daf598c32d0d4025b1683d4dae3895e16308de8353148b5cfc738a82c43e80233c7f5a93285e7e638ee39dded91c63
6
+ metadata.gz: 89bb5114e6463d385d459e9f50645384022311e09aaa76d0a28534840c022be395dcf0c4b4078008f95c69933b15c1444515781992a0088a5b82591710b08112
7
+ data.tar.gz: 7d6afa61c71790ad5753162cc8cd9352df8b839690f68a1c1b341e30a2659b7b4b84d2fa0924fb497981ce928fa617cd85d8aa1b7ffa79fb4f88656edb0b8673
@@ -1,3 +1,3 @@
1
1
  module Ec2ctl
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/ec2ctl.rb CHANGED
@@ -25,12 +25,14 @@ module Ec2ctl
25
25
  class_option :profile
26
26
  class_option :color, default: true, type: :boolean
27
27
 
28
+ option :sort, default: name, aliases: [:S]
29
+ option :limit, type: :numeric, aliases: [:l]
28
30
  desc "list PATTERN", "List all instances in region. Specify PATTERN to filter results by name."
29
31
  def list pattern = ""
30
32
  rows = []
31
33
 
32
34
  ec2.instances.each do |instance|
33
- name = instance.tags["Name"]
35
+ name = instance.tags["Name"].to_s
34
36
  next if !pattern.empty? and !name.match pattern
35
37
 
36
38
  rows << [
@@ -43,6 +45,18 @@ module Ec2ctl
43
45
  ]
44
46
  end
45
47
 
48
+ col = case options[:sort]
49
+ when /ID/i then 0
50
+ when /Name/i then 1
51
+ when /Type/i then 2
52
+ when /private/i then 3
53
+ when /public/i then 4
54
+ when /status/i then 5
55
+ end
56
+
57
+ rows.sort_by! {|row| row[col].to_s} if col
58
+ rows = rows[0, options[:limit]] if options[:limit]
59
+
46
60
  puts Terminal::Table.new headings: ["ID", "Name", "Type", "Private IP", "Public IP", "Status"], rows: rows
47
61
  end
48
62
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2ctl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - y13i
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-07 00:00:00.000000000 Z
11
+ date: 2014-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor