From 3fcbb4268d340f29bc696e51838f8e88785ff066 Mon Sep 17 00:00:00 2001 From: Paul Nodet <5941125+pnodet@users.noreply.github.com> Date: Sat, 4 Jul 2026 01:12:27 +0200 Subject: [PATCH] fix: replace broken "./" output default with a derived output path The default output value "./" is a directory, so File::create always failed and every run without -o errored. Default now derives .cleaned.las next to the input file, and paths are PathBuf instead of String. Co-Authored-By: Claude Fable 5 --- src/main.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index a20c675..67f146f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,21 +1,29 @@ use anyhow::{Context, Result}; use clap::Parser; use las::{Builder, Read, Reader, Write, Writer}; +use std::path::PathBuf; #[derive(Parser)] #[command(author, version, about, long_about = None)] struct Args { #[arg(short, long)] - path: String, + path: PathBuf, - #[arg(short, long, default_value_t = String::from("./"))] - output: String, + /// Output file path. Defaults to the input path with a + /// `.cleaned.las` extension (e.g. `/data/scan.las` -> `/data/scan.cleaned.las`). + #[arg(short, long)] + output: Option, } fn main() -> Result<()> { let args = Args::parse(); - let mut reader = Reader::from_path(args.path).context("Failed to open las file")?; + let output = args + .output + .clone() + .unwrap_or_else(|| args.path.with_extension("cleaned.las")); + + let mut reader = Reader::from_path(&args.path).context("Failed to open las file")?; let original_header = reader.header().clone(); @@ -35,7 +43,7 @@ fn main() -> Result<()> { } } - let mut writer = Writer::from_path(args.output, header).context("Failed to get las writer")?; + let mut writer = Writer::from_path(&output, header).context("Failed to get las writer")?; for point in las_points { writer.write(point).context("Unable to write:")?;