diff options
| author | Stanisław Zagórowski <hasohasacz@gmail.com> | 2024-01-15 19:13:50 +0100 |
|---|---|---|
| committer | Stanisław Zagórowski <hasohasacz@gmail.com> | 2024-01-15 19:13:50 +0100 |
| commit | 4a33970f7d92fda59e67596c4fe58574f83035fc (patch) | |
| tree | f885828e22ed7d9adaf16564d0e1288660976a28 | |
| parent | 78339be9260839d41cf5486ac7a96a5ea26fa81c (diff) | |
fix: default dev directory
| -rw-r--r-- | src/main.rs | 32 |
1 files changed, 14 insertions, 18 deletions
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<std::path::PathBuf>, + 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()); - } + 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 - }; + 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 |
