Class: VagrantPlugins::Provider::StashCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- VagrantPlugins::Provider::StashCommand
- Defined in:
- lib/vagrant-provider/stash-command.rb
Instance Method Summary collapse
Methods inherited from BaseCommand
#active_provider, #line, #machine_folder, #machine_names, #machine_provider, #provider_name, #providers_for
Instance Method Details
#execute ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vagrant-provider/stash-command.rb', line 5 def execute opts = OptionParser.new do |o| o. = "Usage: vagrant provider stash [machine-name]" o.separator "" o.separator "Store current provider state for later" o.separator "" end # Parse the options argv = (opts) return if !argv if argv.length > 1 raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp end machine_name = (argv[0] || @env.primary_machine_name).to_sym if not machine_names.include? machine_name raise Vagrant::Errors::MachineNotFound, name: machine_name end provider = active_provider(machine_name) if not provider raise NoActiveProvider end source = machine_folder.join("#{machine_name}") target = machine_folder.join("#{machine_name}_#{provider[:name]}") if target.exist? raise AlreadyStashedProvider end source.rename(target) line "Stored #{provider[:name]} provider for later use" # Success, exit status 0 0 end |