commands/init: force flag [GH-3564]
This commit is contained in:
parent
90234dc32f
commit
ad961b24f5
|
@ -44,6 +44,7 @@ IMPROVEMENTS:
|
|||
- commands/destroy: Exit codes changes. 0 means everything succeeded.
|
||||
1 means everything was declined. 2 means some were declined. [GH-811]
|
||||
- commands/destroy: Doesn't require box to exist anymore. [GH-1629]
|
||||
- commands/init: force flag. [GH-3564]
|
||||
- commands/rsync-auto: Picks up and syncs provisioner folders if
|
||||
provisioners are backed by rsync.
|
||||
- commands/rsync-auto: Detects when new synced folders were added and warns
|
||||
|
|
|
@ -10,7 +10,10 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def execute
|
||||
options = { output: "Vagrantfile" }
|
||||
options = {
|
||||
force: false,
|
||||
output: "Vagrantfile",
|
||||
}
|
||||
|
||||
opts = OptionParser.new do |o|
|
||||
o.banner = "Usage: vagrant init [name] [url]"
|
||||
|
@ -18,6 +21,10 @@ module VagrantPlugins
|
|||
o.separator "Options:"
|
||||
o.separator ""
|
||||
|
||||
o.on("-f", "--force", "Overwrite existing Vagrantfile") do |f|
|
||||
options[:force] = f
|
||||
end
|
||||
|
||||
o.on("--output FILE", String,
|
||||
"Output path for the box. '-' for stdout") do |output|
|
||||
options[:output] = output
|
||||
|
@ -31,6 +38,7 @@ module VagrantPlugins
|
|||
save_path = nil
|
||||
if options[:output] != "-"
|
||||
save_path = Pathname.new(options[:output]).expand_path(@env.cwd)
|
||||
save_file.delete if save_path.exist? && options[:force]
|
||||
raise Vagrant::Errors::VagrantfileExistsError if save_path.exist?
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue