Sha256: 67ba001423639b33dbb805e0587a69e6b9d6670a9006e27bf0c8d57d785e0a46

Contents?: true

Size: 744 Bytes

Versions: 14

Compression:

Stored size: 744 Bytes

Contents

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

Guignol::Shell.class_eval do
  desc 'kill PATTERNS', 'Terminate all instances matching PATTERNS'
  add_force_option
  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, options = {})
      return true if configs.empty?
      return true if options[:force]
      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

14 entries across 14 versions & 1 rubygems

Version Path
guignol-0.3.16 lib/guignol/commands/kill.rb
guignol-0.3.15 lib/guignol/commands/kill.rb
guignol-0.3.14 lib/guignol/commands/kill.rb
guignol-0.3.13 lib/guignol/commands/kill.rb
guignol-0.3.12 lib/guignol/commands/kill.rb
guignol-0.3.10 lib/guignol/commands/kill.rb
guignol-0.3.9 lib/guignol/commands/kill.rb
guignol-0.3.8 lib/guignol/commands/kill.rb
guignol-0.3.7 lib/guignol/commands/kill.rb
guignol-0.3.6.2 lib/guignol/commands/kill.rb
guignol-0.3.6.1 lib/guignol/commands/kill.rb
guignol-0.3.6 lib/guignol/commands/kill.rb
guignol-0.3.5.1 lib/guignol/commands/kill.rb
guignol-0.3.5 lib/guignol/commands/kill.rb