Skip to content

Commit

Permalink
command: add --mount/--umount options to vagrant sshfs command
Browse files Browse the repository at this point in the history
  • Loading branch information
dustymabe committed Apr 15, 2016
1 parent 8f64fce commit 69d02aa
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lib/vagrant-sshfs/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit 69d02aa

Please sign in to comment.