Sha256: 02f1c32ecd56e475952817b35633af840b1684fecbee16583d1d9d98fd61c1b9

Contents?: true

Size: 1006 Bytes

Versions: 1

Compression:

Stored size: 1006 Bytes

Contents

require 'vagrant-mutate/box'
require 'vagrant-mutate/converter'
require 'vagrant-mutate/provider/provider'

module VagrantMutate

  class Mutate < Vagrant.plugin(2, :command)

    def execute
      opts = OptionParser.new do |o|
        o.banner = 'Usage: vagrant mutate <box-name-or-file> <provider>'
      end
      argv = parse_options(opts)
      return if !argv

      unless argv.length == 2
        @env.ui.info(opts.help)
        return
      end

      box_arg = argv[0]
      output_provider_arg = argv[1]

      c = Converter.new(@env)
      input_box = Box.new(@env)
      output_box = Box.new(@env)

      if box_arg =~ /\.box$/
        input_box.load_from_file(box_arg)
      else
        input_box.load_by_name(box_arg)
      end

      output_box.prepare_for_output( input_box.name, output_provider_arg)

      c.convert(input_box, output_box)

      input_box.cleanup

      @env.ui.info "The box #{output_box.name} (#{output_box.provider.name}) is now ready to use."

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-mutate-0.1.2 lib/vagrant-mutate/mutate.rb