ec2ctl 0.9.7 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ec2ctl/cli.rb +22 -13
- data/lib/ec2ctl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5b98d7b9d9b2dd4e25ba115a464bbfc026a5bff
|
4
|
+
data.tar.gz: 815717a464313caf8711ac002e94abd894d187a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5deacc01b22e5668574e35bedeb9166fad61447cb8ee5c323fc334e3cffb62d91cb358ead0d3760b8f347abaae7bf61e59f3d1ca8fbe1aad86edca50e34cfdd
|
7
|
+
data.tar.gz: 830310f036cfa898145f3d46c6d25f548d5fcdde7d864c56960b2b5cb15cd435ce6545be8d1a11a94f44068d01ae646e4c87aba37c512c7bc08f4b5708fb7868
|
data/lib/ec2ctl/cli.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "commander"
|
2
2
|
require "ec2ctl/logger"
|
3
3
|
require "pathname"
|
4
|
+
require "json"
|
4
5
|
|
5
6
|
module EC2Ctl
|
6
7
|
class CLI
|
@@ -8,7 +9,7 @@ module EC2Ctl
|
|
8
9
|
|
9
10
|
OptionError = Class.new RuntimeError
|
10
11
|
|
11
|
-
|
12
|
+
OPTION_FILE_NAME = ".ec2ctlrc".freeze
|
12
13
|
|
13
14
|
DEFAULT_OPTIONS = {
|
14
15
|
"ec2 list" => {
|
@@ -167,7 +168,7 @@ module EC2Ctl
|
|
167
168
|
private
|
168
169
|
|
169
170
|
def init_client(options)
|
170
|
-
|
171
|
+
global_opt = %i(
|
171
172
|
verbose
|
172
173
|
pretty
|
173
174
|
output
|
@@ -178,7 +179,7 @@ module EC2Ctl
|
|
178
179
|
help
|
179
180
|
)
|
180
181
|
|
181
|
-
@client = EC2Ctl::Client.new options.__hash__.reject {|k, v|
|
182
|
+
@client = EC2Ctl::Client.new options.__hash__.reject {|k, v| global_opt.include? k}.merge(logger: logger)
|
182
183
|
end
|
183
184
|
|
184
185
|
def logger
|
@@ -268,19 +269,12 @@ module EC2Ctl
|
|
268
269
|
|
269
270
|
def handle_options(_command, opt)
|
270
271
|
default_opt = DEFAULT_OPTIONS[_command.name]
|
272
|
+
file_opt = options_from_file[_command.name]
|
271
273
|
|
272
|
-
|
273
|
-
|
274
|
-
JSON.load(File.read(USER_OPTION_FILE_PATH))
|
274
|
+
[default_opt, file_opt].each do |o|
|
275
|
+
o.each {|k, v| opt.default k.intern => v} if o
|
275
276
|
end
|
276
277
|
|
277
|
-
if user_options && user_options[_command.name]
|
278
|
-
user_options[_command.name].each do |k, v|
|
279
|
-
default_opt.update k.intern => v
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
opt.default default_opt if default_opt
|
284
278
|
handle_global_options opt
|
285
279
|
end
|
286
280
|
|
@@ -291,5 +285,20 @@ module EC2Ctl
|
|
291
285
|
ENV["AWS_PROFILE"] = opt.profile if opt.profile
|
292
286
|
ENV["AWS_REGION"] = opt.region if opt.region
|
293
287
|
end
|
288
|
+
|
289
|
+
def options_from_file
|
290
|
+
pathnames = [
|
291
|
+
Pathname.new(Dir.pwd).ascend.to_a,
|
292
|
+
Pathname.new(Dir.home),
|
293
|
+
].flatten.map do |pathname|
|
294
|
+
pathname + OPTION_FILE_NAME
|
295
|
+
end
|
296
|
+
|
297
|
+
pathnames.each do |pathname|
|
298
|
+
return JSON.load File.read(pathname) if File.exists? pathname
|
299
|
+
end
|
300
|
+
|
301
|
+
{}
|
302
|
+
end
|
294
303
|
end
|
295
304
|
end
|
data/lib/ec2ctl/version.rb
CHANGED
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.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoriki Yamaguchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|