From 4a33970f7d92fda59e67596c4fe58574f83035fc Mon Sep 17 00:00:00 2001 From: Stanisław Zagórowski Date: Mon, 15 Jan 2024 19:13:50 +0100 Subject: fix: default dev directory --- src/main.rs | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index b38ee19..881c0d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,9 +72,10 @@ enum Args { #[clap( short = 'P', long = "public-dir", + default_value = ".", help = "The static files directory to serve" )] - public_dir: Option, + public_dir: std::path::PathBuf, #[clap( short = 'p', long = "port", @@ -149,24 +150,19 @@ async fn main() -> color_eyre::Result<()> { println!("🌴 Project root: {}", change_dir.display().bright_yellow()); - let public_dir = if let Some(public_dir) = public_dir { - if !public_dir.is_dir() { - return Err(std::io::Error::new( - std::io::ErrorKind::NotFound, - format!("{} is not a directory", public_dir.display()), - ) - .into()); - } - - println!( - "🌴 Public directory: {}", - public_dir.display().bright_yellow() - ); - Some(public_dir.canonicalize()?) - } else { - println!("🌴 Public directory: {}", "none".bright_yellow()); - None - }; + if !public_dir.is_dir() { + return Err(std::io::Error::new( + std::io::ErrorKind::NotFound, + format!("{} is not a directory", public_dir.display()), + ) + .into()); + } + + println!( + "🌴 Public directory: {}", + public_dir.display().bright_yellow() + ); + let public_dir = Some(public_dir.canonicalize()?); if local { serve_locally(change_dir, true, port, public_dir).await -- cgit v1.3.1