dergachev/vagrant-vbox-snapshot

Merge subcommand "snapshot back" into "snapshot go"

dergachev opened this issue · 9 comments

Currently we have the following:

vagrant snapshot            # shows usage
vagrant snapshot list       # shows list of snapshots
vagrant snaphot take NAME   # creates snapshot NAME  
vagrant snapshot back       # restores last created snaphot
vagrant snapshot go NAME    # restores to snapshot NAME 

I'd like to merge "go" and "back" together, to have a more minimalistic API:

vagrant snapshot            # shows usage
vagrant snapshot list       # list of snapshots
vagrant snaphot take NAME   # creates snapshot named NAME
vagrant snapshot go [NAME]  # restores snapshot NAME, or most recent snaphot

Anyone has thoughts?

👍 I like the idea :)

I just used vagrant snapshot back on a halted VM (to restore to a previous halted state); and was surprised to find that the default behavior is to start the VM immediately. Is that the assumed behavior? If so, I think that should be modified so that the default is to simply restore the halted VM (assuming the restore point is also in halted state).

Maybe a --no-start or --no-up switch could be added.

I think if the current state is halted, and the snapshot state is halted, the extra flag (perhaps --start) would optionally run the VM. By default though vagrant snapshot back (in this scenario) shouldn't run the VM. In my case, my workflow was that I was working on some Puppet / CM scripts during the day and when I was closing up shop for the night, wanted to set my VM state back to where I'd begin work the next day.

You'd call vagrant snapshot back --no-start then
No need to break everyone else's scripts by changing the default behaviour.

Ah, fair enough. I hadn't considered current consumers. I agree with you.

It's a good idea, but a separate issue, btw :)
This looks like it's just about merging "back" into go.

On that topic: "vagrant snapshot back" says what it does. "vagrant snapshot go" without a parameter doesn't.
Merging the code for the two is a good idea, to reduce code duplication, but at least have "back" as an alias for "go" without a parameter. Hidden if need be

I like it 👍

I'd welcome a PR for this. :)