def execute
options = {:unmount => false}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant sshfs [--mount|--unmount] [vm-name]"
o.separator ""
o.separator "Mount or unmount sshfs synced folders into the vagrant box"
o.separator ""
o.on("--mount", "Mount folders - the default") do
options[:unmount] = false
end
o.on("--unmount", "Unmount folders") do
options[:unmount] = true
end
end
argv = parse_options(opts)
return if !argv
error = false
with_target_vms(argv) do |machine|
if !machine.communicate.ready?
machine.ui.error(I18n.t("vagrant.sshfs.errors.communicator_not_ready"))
error = true
next
end
folders = synced_folders(machine, cached: false)[:sshfs]
next if !folders || folders.empty?
if options[:unmount]
SyncedFolder.new.disable(machine, folders, {})
else
SyncedFolder.new.enable(machine, folders, {})
end
end
return error ? 1 : 0
end