summaryrefslogtreecommitdiff
path: root/lua/rclone.lua
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2022-01-22 22:00:11 +0100
committerDaniel Weipert <code@drogueronin.de>2022-01-22 22:00:11 +0100
commitc9c56716c50593f88ea2c3a89248a95dcb649f7a (patch)
tree9a5ec12e6cf1d2faa9700a0baa2a51833cc61e05 /lua/rclone.lua
parent7092ea034b5cbfc8f3a2029bb9380e1db57472e9 (diff)
Add mount command
Diffstat (limited to 'lua/rclone.lua')
-rw-r--r--lua/rclone.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/lua/rclone.lua b/lua/rclone.lua
index c5623b8..d7e14c7 100644
--- a/lua/rclone.lua
+++ b/lua/rclone.lua
@@ -409,6 +409,43 @@ local function sync(options)
return config
end
+---
+-- Call the 'rclone mount' command with config values
+-- 'rclone mount <args>'
+--
+-- @return any
+local function mount(options)
+ local remote, config = get_remote_config(options.remote)
+ if remote == nil then
+ return
+ end
+
+ local local_path = prepare_cmd_local_path(config)
+ local remote_path = build_cmd_remote_path(config, remote)
+
+ local mount_directory = options['directory'] or
+ config.vim_rclone_mount_directory or
+ vim.g.vim_rclone_mount_directory or
+ 'rclone.mount'
+ local local_mount_path = local_path .. '/' .. mount_directory
+
+ local cmd =
+ 'rclone mount ' ..
+ remote_path .. ' ' ..
+ local_mount_path .. ' ' ..
+ build_cmd_config() .. ' ' ..
+ '--log-format=pid --log-file=' .. vim.fn.stdpath('data') .. '/rclone_nvim/rclone-mount.log' .. ' ' ..
+ '--read-only --no-checksum' .. ' ' ..
+ '--daemon'
+
+ if options['--dry-run'] then
+ print(cmd)
+ else
+ os.execute('mkdir ' .. local_mount_path)
+ os.execute(cmd)
+ end
+end
+
-- Table for dynamic command access
local commands = {
copy = copy,
@@ -416,6 +453,7 @@ local commands = {
download = download,
downloadFile = downloadFile,
sync = sync,
+ mount = mount,
}
---