Unverified Commit 8e8ca081 authored by Nugine's avatar Nugine
Browse files

s3s-fs: check cli args

see #78
parent 0b431e2d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -20,6 +20,12 @@ impl Error {
        log(&*source);
        Self { source }
    }

    #[must_use]
    #[track_caller]
    pub fn from_string(s: impl Into<String>) -> Self {
        Self::new(s.into().into())
    }
}

impl<E> From<E> for Error
+18 −3
Original line number Diff line number Diff line
@@ -55,11 +55,26 @@ fn setup_tracing() {
        .init();
}

#[tokio::main]
async fn main() -> Result {
    setup_tracing();
fn check_cli_args(opt: &Opt) -> Result<(), String> {
    if let Some(ref s) = opt.domain_name {
        if s.contains('/') {
            return Err(format!("expected domain name, found URL-like string: {s:?}"));
        }
    }
    Ok(())
}

fn main() -> Result {
    let opt = Opt::parse();
    check_cli_args(&opt).map_err(s3s_fs::Error::from_string)?;

    setup_tracing();

    run(opt)
}

#[tokio::main]
async fn run(opt: Opt) -> Result {
    // Setup S3 provider
    let fs = FileSystem::new(opt.root)?;