Jon Topper 7ba398ead8 Add --no-delete to 'snapshot pop' command
In our test environments, it's good to be able to roll back to the same,
anonymous, snapshot repeatedly.  This patch adds a `--no-delete` option
to the `snapshot pop` command allowing this.

This makes the new core snapshot behaviour more consistent with what we
were doing with vagrant-multiprovider-snap
(https://github.com/scalefactory/vagrant-multiprovider-snap)
2016-01-15 18:21:47 +00:00

34 lines
828 B
Ruby

require 'json'
require 'optparse'
require_relative "push_shared"
module VagrantPlugins
module CommandSnapshot
module Command
class Pop < Vagrant.plugin("2", :command)
include PushShared
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant snapshot pop [options] [vm-name]"
o.separator ""
o.separator "Restore state that was pushed with `vagrant snapshot push`."
o.on("--no-delete", "Don't delete the snapshot after the restore") do
options[:no_delete] = true
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
return shared_exec(argv, method(:pop), options)
end
end
end
end
end