diff options
| author | Daniel Weipert <code@drogueronin.de> | 2022-01-22 22:00:11 +0100 | 
|---|---|---|
| committer | Daniel Weipert <code@drogueronin.de> | 2022-01-22 22:00:11 +0100 | 
| commit | c9c56716c50593f88ea2c3a89248a95dcb649f7a (patch) | |
| tree | 9a5ec12e6cf1d2faa9700a0baa2a51833cc61e05 /lua | |
| parent | 7092ea034b5cbfc8f3a2029bb9380e1db57472e9 (diff) | |
Add mount command
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/rclone.lua | 38 | 
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,  }  ---  | 
