lib/vagrant/commands/init.rb in vagrant-0.5.1 vs lib/vagrant/commands/init.rb in vagrant-0.5.2
- old
+ new
@@ -3,30 +3,34 @@
class Init < Base
Base.subcommand "init", self
description "Initializes current folder for Vagrant usage"
def execute(args)
- create_vagrantfile(args[0])
+ create_vagrantfile(:default_box => args[0] , :default_box_url => args[1])
end
def options_spec(opts)
- opts.banner = "Usage: vagrant init [name]"
+ opts.banner = "Usage: vagrant init [name] [box_url]"
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)
+ # @param [String] :default_box The default base box for this
+ # Vagrantfile
+ # @param [String] :default_box_url The default url for fetching
+ # the given box for the Vagrantfile
+ def create_vagrantfile(opts={})
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"
+ # Set the defaults of the Vagrantfile
+ opts[:default_box] ||= "base"
+
File.open(rootfile_path, 'w+') do |f|
- f.write(TemplateRenderer.render(Environment::ROOTFILE_NAME, :default_box => default_box))
+ f.write(TemplateRenderer.render(Environment::ROOTFILE_NAME, opts))
end
end
end
end
-end
\ No newline at end of file
+end