Skip to content

Commit 447e605

Browse files
author
Peter Benjamin
committed
Prettify output and add AMI feature
1 parent e2d948b commit 447e605

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

source/bin/restacker

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ACTIONS = {
1414
remove: 'Removes the given deployment',
1515
configure: 'Configure the target account in the restacker.yml file',
1616
dump: 'Dumps the default configuration for a given template or module',
17+
amis: 'Shows latest AMIs in S3 bucket',
1718
console: 'Opens the AWS Console'
1819
}
1920
ACTIONS_HELP = "ACTIONS\n\n" + ACTIONS.to_yaml.sub("---\n", '').gsub(': ', "\t").gsub(':', " ")
@@ -116,36 +117,32 @@ begin
116117
action = unparsed.pop
117118
puts(VERSION) || exit(0) if options[:version]
118119
usage("Please specify an ACTION") && exit(0) if action.nil?
120+
plane = RestackerConfig.get_plane(options)
119121

120122
if action == 'configure'
121-
plane = RestackerConfig.get_plane(options)
122-
if !plane
123-
puts "Location not specified, plane is set to default: [#{DEFAULT_PLANE}]"
124-
end
125-
puts "Configuring target plane [#{plane}]: "
126-
RestackerConfig.load_config(plane.to_sym)
127-
Restacker.configure(plane.to_sym)
123+
printf "%-30s : %s\n", Rainbow("CONFIGURING PLANE").white.bright.underline, plane
124+
RestackerConfig.configure(plane)
128125
exit(0)
129126
end
130127

131128
if ACTIONS.keys.push(:aws).include?(action.to_sym)
132-
restacker = Restacker.new(options.to_h) unless ['dump'].include?(action)
129+
restacker = Restacker.new(options.to_h) unless ['dump', 'amis'].include?(action)
133130
case action
134131
when 'list'
135-
puts Rainbow("LISTING STACKS").white.bright.underline
132+
printf "%-30s : %s\n", Rainbow("LISTING STACKS").white.bright.underline, plane
136133
restacker.list_stacks
137134
when 'desc', 'describe'
138135
if options[:name]
139-
puts "Describing #{options[:name]}"
136+
puts Rainbow("DESCRIBING STACK").white.bright.underline
140137
restacker.describe_stack(options[:name])
141138
else
142139
usage "Please specify a stack name (-n) to describe"
143140
end
144141
when 'restack'
145142
if options[:name]
146-
puts "Restacking #{options[:name]}"
143+
printf "%-30s : %s\n", Rainbow("RESTACKING").white.bright.underline, options[:name]
147144
restacker.restack_by_name(options[:name])
148-
puts "Now run migrate followed by remove"
145+
puts Rainbow("Now run migrate followed by remove").white.bright
149146
else
150147
usage "Please specify a stack name (-n) to restack"
151148
end
@@ -165,18 +162,20 @@ begin
165162
end
166163
when 'remove'
167164
if options[:name]
168-
puts "Removing stack"
165+
printf "%-30s : %s\n", Rainbow("REMOVING STACK").white.bright.underline, options[:name]
169166
restacker.delete_stack(options[:name])
170167
else
171168
usage "Please specify a stack name (-n) to remove"
172169
end
173170
when 'dump'
174171
if options[:template]
175-
# puts "Dumping stack parameters"
176172
Restacker.dump_stack_params(options)
177173
else
178174
usage "Please specify a stack template (-t) or module (-m)"
179175
end
176+
when 'amis'
177+
puts Rainbow("SHOWING AMIS").white.bright.underline
178+
Restacker.amis
180179
when 'console'
181180
AwsCli.new(options).console(options)
182181
when 'aws'

0 commit comments

Comments
 (0)