From 69d02aa4f0cfe04027aed9a5682a9852842fe0f4 Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Thu, 14 Apr 2016 20:51:57 -0400 Subject: [PATCH] command: add --mount/--umount options to vagrant sshfs command --- lib/vagrant-sshfs/command.rb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/vagrant-sshfs/command.rb b/lib/vagrant-sshfs/command.rb index 70cc140..3e9cc03 100644 --- a/lib/vagrant-sshfs/command.rb +++ b/lib/vagrant-sshfs/command.rb @@ -10,11 +10,19 @@ def self.synopsis end def execute + options = {:unmount => false} # Default to mounting shares opts = OptionParser.new do |o| - o.banner = "Usage: vagrant sshfs" + o.banner = "Usage: vagrant sshfs [--mount|--unmount] [vm-name]" o.separator "" - o.separator "Mount all sshfs synced folders into the vagrant box" + 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 # Parse the options and return if we don't have any target. @@ -36,8 +44,12 @@ def execute folders = synced_folders(machine, cached: false)[:sshfs] next if !folders || folders.empty? - # Sync them! - SyncedFolder.new.enable(machine, folders, {}) + # Mount or Unmount depending on the user's request + if options[:unmount] + SyncedFolder.new.disable(machine, folders, {}) + else + SyncedFolder.new.enable(machine, folders, {}) + end end return error ? 1 : 0 end