From 50f1931fffa5a0ea00c1d1145084e0c05937e023 Mon Sep 17 00:00:00 2001 From: yuhui Date: Fri, 3 Jan 2025 10:36:46 +0800 Subject: [PATCH] Handle args --- clients/filesystem-fuse/src/main.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/clients/filesystem-fuse/src/main.rs b/clients/filesystem-fuse/src/main.rs index 623567f0161..3534e033465 100644 --- a/clients/filesystem-fuse/src/main.rs +++ b/clients/filesystem-fuse/src/main.rs @@ -26,17 +26,25 @@ use tokio::signal; async fn main() -> fuse3::Result<()> { tracing_subscriber::fmt().init(); + // todo need inmprove the args parsing + let args: Vec = std::env::args().collect(); + let (mount_point, mount_from, config_path) = match args.len() { + 4 => (args[1].clone(), args[2].clone(), args[3].clone()), + _ => { + error!("Usage: {} ", args[0]); + return Err(Errno::from(libc::EINVAL)); + } + }; + //todo(read config file from args) - let config = AppConfig::from_file(Some("conf/gvfs_fuse.toml")); + let config = AppConfig::from_file(Some(&config_path)); if let Err(e) = &config { error!("Failed to load config: {:?}", e); return Err(Errno::from(libc::EINVAL)); } let config = config.unwrap(); - let mount_point = "gvfs"; - let mount_from = "gvfs://fileset/test/c1/s1/fileset1"; let handle = tokio::spawn(async move { - let result = gvfs_mount(mount_point, mount_from, &config).await; + let result = gvfs_mount(&mount_point, &mount_from, &config).await; if let Err(e) = result { error!("Failed to mount gvfs: {:?}", e); return Err(Errno::from(libc::EINVAL));