Sha256: 4cac1ce824015041dbe19e5c53bd00b1341e59d2eae62c978f2508cfc28bc7f8

Contents?: true

Size: 960 Bytes

Versions: 43

Compression:

Stored size: 960 Bytes

Contents

module Vagrant
  module Command
    module Helpers
      # Initializes the environment by pulling the environment out of
      # the configuration hash and sets up the UI if necessary.
      def initialize_environment(args, options, config)
        raise Errors::CLIMissingEnvironment if !config[:env]
        @env = config[:env]
      end

      # This returns an array of {VM} objects depending on the arguments
      # given to the command.
      def target_vms(name=nil)
        raise Errors::NoEnvironmentError if !env.root_path

        name ||= self.name rescue nil

        @target_vms ||= begin
          if env.multivm?
            return env.vms_ordered if !name
            vm = env.vms[name.to_sym]
            raise Errors::VMNotFoundError, :name => name if !vm
          else
            raise Errors::MultiVMEnvironmentRequired if name
            vm = env.vms.values.first
          end

          [vm]
        end
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 5 rubygems

Version Path
vagrant-0.7.0.beta2 lib/vagrant/command/helpers.rb
vagrant-0.7.0.beta lib/vagrant/command/helpers.rb
vagrant-0.6.9 lib/vagrant/command/helpers.rb