From 87f6fe9d75798883b29621297e74d7a002b1961c Mon Sep 17 00:00:00 2001 From: dusk Date: Sat, 29 Mar 2025 14:51:58 +0900 Subject: [PATCH] refactor(command_parser): improve the invalid flags error --- crates/command_parser/src/lib.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/crates/command_parser/src/lib.rs b/crates/command_parser/src/lib.rs index f149aac3..0a444915 100644 --- a/crates/command_parser/src/lib.rs +++ b/crates/command_parser/src/lib.rs @@ -182,16 +182,9 @@ pub fn parse_command( } write!( &mut error, - " {} not applicable in this command (`{prefix}{input}`). Applicable flags are the following:", - (invalid_flags.len() > 1).then_some("are").unwrap_or("is") + " {} seem to be applicable in this command (`{prefix}{command}`).", + (invalid_flags.len() > 1).then_some("don't").unwrap_or("doesn't") ).expect("oom"); - for (idx, flag) in command.flags.iter().enumerate() { - write!(&mut error, " `{flag}`").expect("oom"); - if idx < command.flags.len() - 1 { - error.push_str(", "); - } - } - error.push_str("."); return Err(error); } println!("{} {flags:?} {params:?}", command.cb);