Sha256: 12664ebaee46799e5380f17fb63b3b7d34e45848dc4eaa2c4e8f59fd8d6e5009

Contents?: true

Size: 674 Bytes

Versions: 5

Compression:

Stored size: 674 Bytes

Contents

require 'guignol/commands/base'
require 'guignol/models/instance'

Guignol::Shell.class_eval do
  desc 'kill PATTERNS', 'Terminate all instances matching PATTERNS'
  def kill(*patterns)
    if patterns.empty?
      raise Thor::Error.new('You must specify at least one PATTERN.')
    end
    Guignol::Commands::Kill.new(patterns).run
  end
end


module Guignol::Commands
  class Kill < Base

    def before_run(configs)
      return true if configs.empty?
      names = configs.keys.join(", ")
      shell.yes? "Are you sure you want to destroy servers #{names}? [y/N]", :cyan
    end

    def run_on_server(instance, options = {})
      instance.destroy
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
guignol-0.3.4 lib/guignol/commands/kill.rb
guignol-0.3.3 lib/guignol/commands/kill.rb
guignol-0.3.2 lib/guignol/commands/kill.rb
guignol-0.3.1 lib/guignol/commands/kill.rb
guignol-0.3.0 lib/guignol/commands/kill.rb