diff --git a/CHANGELOG.md b/CHANGELOG.md index 52b88ac..b2fdf21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to Puddi are recorded here. The format follows [Keep a Chang ### Fixed +- `pud add --name` requires a value instead of silently defaulting. - `pud doc` preserves paragraph breaks in module documentation. - Integer literals too large for the compiler's integer representation report an error instead of wrapping. - List pattern exhaustiveness accounts for the exact lengths covered by rest patterns. diff --git a/src/main.rs b/src/main.rs index 49bf1a1..156b9bc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -508,7 +508,10 @@ fn main() -> ExitCode { "--check" => check_only = true, "--name" => { i += 1; - name_opt = opts.get(i).cloned(); + match opts.get(i) { + Some(n) => name_opt = Some(n.clone()), + None => return fail("--name needs a value"), + } } "-o" | "--out" => { i += 1; diff --git a/tests/run.rs b/tests/run.rs index 00b4862..b1d6e08 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -132,3 +132,11 @@ fn plugin_host_capabilities() { // the jobs are timed on their own, then the worker answers assert!(text.contains(r#"["job2", "job1", "job0", "concurrent true", "worker Some(49)"]"#), "{text}"); } + +#[test] +fn pud_add_name_requires_value() { + let out = pud().args(["add", "foo", "--name"]).output().unwrap(); + assert!(!out.status.success()); + let stderr = String::from_utf8_lossy(&out.stderr); + assert!(stderr.contains("--name needs a value"), "{stderr}"); +}