Sha256: 8caa0796fea761f4f48103cb16ee98d19c83bfb521099f1e35dd6c09f0f0c8fe

Contents?: true

Size: 1.03 KB

Versions: 18

Compression:

Stored size: 1.03 KB

Contents

module Vagrant
  class Commands
    class Init < Base
      Base.subcommand "init", self
      description "Initializes current folder for Vagrant usage"

      def execute(args)
        create_vagrantfile(args[0])
      end

      def options_spec(opts)
        opts.banner = "Usage: vagrant init [name]"
      end

      # Actually writes the initial Vagrantfile to the current working directory.
      # The Vagrantfile will contain the base box configuration specified, or
      # will just use "base" if none is specified.
      #
      # @param [String] default_box The default base box for this Vagrantfile
      def create_vagrantfile(default_box=nil)
        rootfile_path = File.join(Dir.pwd, Environment::ROOTFILE_NAME)
        error_and_exit(:rootfile_already_exists) if File.exist?(rootfile_path)

        # Write the rootfile
        default_box ||= "base"
        File.open(rootfile_path, 'w+') do |f|
          f.write(TemplateRenderer.render(Environment::ROOTFILE_NAME, :default_box => default_box))
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
vagrantup-0.5.1 lib/vagrant/commands/init.rb
vagrantup-0.5.0 lib/vagrant/commands/init.rb
vagrantup-0.4.3.dev lib/vagrant/commands/init.rb
vagrantup-0.4.1 lib/vagrant/commands/init.rb
vagrantup-0.4.0 lib/vagrant/commands/init.rb
vagrantup-0.3.4 lib/vagrant/commands/init.rb
vagrantup-0.3.3 lib/vagrant/commands/init.rb
vagrantup-0.3.2 lib/vagrant/commands/init.rb
vagrantup-0.3.1 lib/vagrant/commands/init.rb
vagrant-0.5.1 lib/vagrant/commands/init.rb
vagrant-0.5.0 lib/vagrant/commands/init.rb
vagrant-0.4.2 lib/vagrant/commands/init.rb
vagrant-0.4.1 lib/vagrant/commands/init.rb
vagrant-0.4.0 lib/vagrant/commands/init.rb
vagrant-0.3.4 lib/vagrant/commands/init.rb
vagrant-0.3.3 lib/vagrant/commands/init.rb
vagrant-0.3.2 lib/vagrant/commands/init.rb
vagrant-0.3.1 lib/vagrant/commands/init.rb