From c9c56716c50593f88ea2c3a89248a95dcb649f7a Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sat, 22 Jan 2022 22:00:11 +0100 Subject: Add mount command --- lua/rclone.lua | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) 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 ' +-- +-- @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, } --- -- cgit v1.2.3