From 352a486fee986118a2865316d2d1ab8e6de69b48 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 6 Jun 2021 19:57:26 +0200 Subject: main: Remove `unwrap` when parsing `--skip-larger-than` Don't panic here so we can use our own error message template. --- src/main.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index af1319d..b0474bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,14 +77,16 @@ fn run() -> anyhow::Result<()> { let mirror_root = &opt_matches.free[1]; let max_repo_size_bytes = opt_matches.opt_str("skip-larger-than") - .map(|s| - parse_size(&s) - .with_context(|| format!( - "unable to parse max file size '{}'", - s - )) - .unwrap() - ); + .map_or( + Ok(None), + |s| + parse_size(&s) + .map(|s| Some(s)) + .with_context(|| format!( + "unable to parse max file size '{}'", + s + )) + )?; let base_cgitrc = opt_matches.opt_str("cgitrc") .map(|s| PathBuf::from(s)); -- cgit v1.2.3