Class: Fum::Commands::Terminate
- Inherits:
-
Fum::Command
- Object
- Fum::Command
- Fum::Commands::Terminate
- Defined in:
- lib/fum/commands/terminate.rb
Instance Method Summary collapse
Methods inherited from Fum::Command
Methods included from Util
Constructor Details
This class inherits a constructor from Fum::Command
Instance Method Details
#execute(options) ⇒ Object
-
:type
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fum/commands/terminate.rb', line 20 def execute() stage_name = [:stage_name] stage_decl = stage(@application.main_decl, stage_name) analyzer = StageAnalyzer.new(stage_decl) analyzer.analyze() env_info = analyzer.env_map.values targets = [] if [:all] targets = env_info.map { |e| e[:env] } else targets = env_info.select { |e| e[:state] == :inactive }.map { |e| e[:env] } end if targets.length > 0 targets.each { |target| if target.ready? puts "Terminating inactive environment #{target.name}." target.destroy end } else puts "No environments to terminate." end end |
#parse_options ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fum/commands/terminate.rb', line 5 def opts = Trollop:: do "usage: terminate [options] <stage>, where options are:" opt :all, "Terminate all environments for this stage (use with caution)." end if ARGV.empty? die "Please specify a stage name type to terminate." end opts[:stage_name] = ARGV.shift opts end |