swa 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edb6eed402b48a9becd4603b16ce035cbfb4506b
4
- data.tar.gz: 01990ca10d51726866bd933ce6b1393f7f5c076e
3
+ metadata.gz: 5aa99633a7562065e12b0eda658a5eb0cb500298
4
+ data.tar.gz: bcf698098737d8e568952ed7db966abf9bc28b75
5
5
  SHA512:
6
- metadata.gz: c94db3dd53d1fd461c2ef75ee64e47db90d8efee0d26ac5547713ffd5c547e6bed0dae2cb4d8ffe5dfd6a07fc694c684a2cef2b11dbfafddf6ecfa4a140c5bea
7
- data.tar.gz: fac54c6cef75b2c85d12cb974a4084eb8556b87588ff133a50c1997b915abfdcbdbaf2f944cd9ff588886a54c669863a5526fd8eed7572adb55358963a428262
6
+ metadata.gz: c364ab568630bd03aca0d497db0bf6d3e292f9558764e9f3242ea8b8cf044290e5c6be28abd1fd8b11ac991578073fcfd01e082ecb6192837417d89c17ee0044
7
+ data.tar.gz: 04a8bf044e19cecbd4825a9c505eadd35c3b7d1076a9c7733ebf983d403504f56c154ef82f0dc5403eb5336c649590d0353d642f636b55d1bf8630d283c8f179
data/README.md CHANGED
@@ -1,6 +1,67 @@
1
1
  # SWA
2
2
 
3
- It's an alternative CLI for AWS.
3
+ SWA is AWS, backwards.
4
+
5
+ It's an alternative CLI for AWS. "Backwards" because commands put verbs at the end:
6
+
7
+ $ swa ec2 instance i-9336f049 terminate
8
+
9
+ rather than the front:
10
+
11
+ $ aws ec2 terminate-instances --instance-ids i-9336f049
12
+
13
+ ## Listing things
14
+
15
+ SWA provides sub-commands for listing many types of AWS resource, e.g.
16
+
17
+ $ swa ec2 instances
18
+
19
+ Listing commands typically provide options for refining the search:
20
+
21
+ $ swa ec2 instances --tagged purpose=QA --filter availability-zone=ap-southeast-2b
22
+
23
+ By default you'll get a "summary" view, one line per resource:
24
+
25
+ $ swa ec2 instances | head
26
+ i-bcf48c2b ami-1e73737d c3.large running 10.47.5.16
27
+ i-1990d85c ami-538e7330 t2.micro running 10.47.7.25 "blarg/room-service"
28
+ i-f9e6ea27 ami-8bfd7eb1 t2.small running 10.47.11.54 "blarg/match-feed"
29
+ i-19155e5c ami-d5327ab6 c3.large running 10.47.6.238 "fnord-snarfer"
30
+ i-26357e63 ami-eded7ed7 t2.micro running 10.47.6.96 "fnord-dashboard"
31
+ i-b85f6c87 ami-695a7253 c3.xlarge running 10.47.5.252 "bam-boozle"
32
+ i-5627e187 ami-d9d779ba c4.2xlarge running 10.47.11.201 "pub-batch-42"
33
+ i-ced5ae59 ami-eded7ed7 t2.micro running 10.47.6.22 "atlas-hugged"
34
+ i-63e722b2 ami-8bfd7eb1 t2.small running 10.47.8.95 "blarg/first-service"
35
+
36
+ But you can ask for **all** the data, if you wish:
37
+
38
+ $ swa ec2 instances data
39
+ ---
40
+ - InstanceId: i-bcf48c2b
41
+ ImageId: ami-1e73537d
42
+ State:
43
+ Code: 16
44
+ Name: running
45
+ PrivateDnsName: ip-10-48-9-16.ap-southeast-2.compute.internal
46
+ PublicDnsName: ''
47
+ ...
48
+
49
+ Specify `-J` if you like JSON better than YAML.
50
+
51
+ ## Inspecting things
52
+
53
+ Each "collection" operation has a corresponding "item" operation, e.g.
54
+
55
+ $ swa ec2 instance i-bcf48c2b ...
56
+
57
+ Different resource-types support different sub-commands, but they all implement `data`, which again dumps everything in YAML or JSON format.
58
+
59
+ $ swa ec2 instance i-bcf48c2b data
60
+
61
+ The "item" sub-command can be ommitted, when it can be inferred from the resource-id:
62
+
63
+ $ swa ec2 i-bcf48c2b data
64
+ $ swa ec2 ami-1e73737d data
4
65
 
5
66
  ## Contributing
6
67
 
@@ -74,7 +74,7 @@ module Swa
74
74
  unless %w(JSON YAML).member?(arg)
75
75
  raise ArgumentError, "unrecognised data format: #{arg.inspect}"
76
76
  end
77
- @format = arg
77
+ @output_format = arg
78
78
  end
79
79
 
80
80
  def format_data(data)
@@ -5,7 +5,7 @@ module Swa
5
5
  protected
6
6
 
7
7
  def quoted(value)
8
- %("#{value}") if value
8
+ %("#{value}") if value && !value.empty?
9
9
  end
10
10
 
11
11
  def pad(s, width)
@@ -10,9 +10,10 @@ module Swa
10
10
 
11
11
  def summary
12
12
  [
13
- pad(ami.image_id, 13),
13
+ pad(ami.image_id, 12),
14
+ ami.creation_date.sub(".000Z", "Z"),
14
15
  quoted(name)
15
- ].join(" ")
16
+ ].join(" ")
16
17
  end
17
18
 
18
19
  def name
@@ -11,14 +11,14 @@ module Swa
11
11
 
12
12
  def summary
13
13
  [
14
- pad(i.instance_id, 11),
15
- pad(i.image_id, 13),
14
+ pad(i.instance_id, 10),
15
+ pad(i.image_id, 12),
16
16
  pad(i.instance_type, 10),
17
- pad(i.state.name, 11),
18
- pad(i.private_ip_address, 15),
19
- pad(i.public_ip_address, 15),
17
+ pad(i.state.name, 10),
18
+ pad(i.private_ip_address, 14),
19
+ pad(i.public_ip_address, 14),
20
20
  quoted(name)
21
- ].join(" ")
21
+ ].join(" ")
22
22
  end
23
23
 
24
24
  def name
@@ -7,9 +7,9 @@ module Swa
7
7
 
8
8
  def summary
9
9
  [
10
- pad(name, 45),
10
+ pad(name, 4),
11
11
  aws_resource.key_fingerprint
12
- ].join(" ")
12
+ ].join(" ")
13
13
  end
14
14
 
15
15
  def name
@@ -8,10 +8,10 @@ module Swa
8
8
 
9
9
  def summary
10
10
  [
11
- pad(sg.group_id, 12),
12
- pad(sg.vpc_id, 13),
11
+ pad(sg.group_id, 11),
12
+ pad(sg.vpc_id, 12),
13
13
  quoted(sg.group_name)
14
- ].join(" ")
14
+ ].join(" ")
15
15
  end
16
16
 
17
17
  def name
@@ -13,11 +13,11 @@ module Swa
13
13
  [
14
14
  pad(s.snapshot_id, 13),
15
15
  pad(s.volume_id, 12),
16
- sprintf("%4d ", s.volume_size),
16
+ sprintf("%4d", s.volume_size),
17
17
  s.start_time.iso8601,
18
- rpad(s.progress, 5),
18
+ rpad(s.progress, 4),
19
19
  quoted(s.description)
20
- ].join(" ")
20
+ ].join(" ")
21
21
  end
22
22
 
23
23
  extend Forwardable
@@ -11,19 +11,24 @@ module Swa
11
11
 
12
12
  def summary
13
13
  [
14
- pad(v.volume_id, 13),
15
- pad(v.snapshot_id, 14),
16
- sprintf("%5d", v.size),
17
- pad(v.volume_type, 10),
18
- pad(v.state, 11),
14
+ pad(v.volume_id, 12),
15
+ pad(v.snapshot_id, 13),
16
+ sprintf("%4d", v.size),
17
+ pad(v.volume_type, 9),
18
+ pad(attachment.instance_id, 10),
19
+ pad(attachment.device, 9),
19
20
  quoted(name)
20
- ].join(" ")
21
+ ].join(" ")
21
22
  end
22
23
 
23
24
  def name
24
25
  tags["Name"]
25
26
  end
26
27
 
28
+ def attachment
29
+ v.attachments.first || OpenStruct.new
30
+ end
31
+
27
32
  extend Forwardable
28
33
 
29
34
  def_delegators :v, :delete
@@ -1,3 +1,3 @@
1
1
  module Swa
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams