From 5f775ac45fb4144db2287c76dc69ff8142e6fa13 Mon Sep 17 00:00:00 2001 From: Glenn Date: Sat, 5 Oct 2024 10:54:40 +0200 Subject: [PATCH] feat: add support for sshfs option (-o) in config --- src/cli.cr | 2 +- src/main.cr | 6 +++--- src/models/sshfs_config.cr | 18 +++++++++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/cli.cr b/src/cli.cr index 4366d07..04fa16f 100644 --- a/src/cli.cr +++ b/src/cli.cr @@ -16,7 +16,7 @@ module GX class Cli Log = ::Log.for("cli") - @config : GX::Config + @config : GX::Config def initialize # Main execution starts here diff --git a/src/main.cr b/src/main.cr index 28e57a4..c02ff74 100644 --- a/src/main.cr +++ b/src/main.cr @@ -31,6 +31,6 @@ Log.setup do |config| end end -app = GX::Cli.new -app.parse_command_line(ARGV) -app.run +cli = GX::Cli.new +cli.parse_command_line(ARGV) +cli.run diff --git a/src/models/sshfs_config.cr b/src/models/sshfs_config.cr index 99da441..898ccdb 100644 --- a/src/models/sshfs_config.cr +++ b/src/models/sshfs_config.cr @@ -13,6 +13,7 @@ module GX::Models getter remote_user : String = "" getter remote_host : String = "" getter remote_port : String = "22" + getter options : Array(String) = [] of String include Concerns::Base @@ -28,13 +29,19 @@ module GX::Models mount_point_safe = @mount_point raise InvalidMountpointError.new("Invalid mount point") if mount_point_safe.nil? + options = [] of String + # merge sshfs options + @options.each do |option| + options.push("-o", option) + end + options.push("-p", remote_port) + options.push( + "#{@remote_user}@#{@remote_host}:#{@remote_path}", + mount_point_safe + ) process = Process.new( "sshfs", - [ - "-p", remote_port, - "#{@remote_user}@#{@remote_host}:#{@remote_path}", - mount_point_safe, - ], + options, input: STDIN, output: STDOUT, error: STDERR @@ -43,3 +50,4 @@ module GX::Models end end end +