mirror of
https://github.com/nushell/nushell.git
synced 2025-08-21 17:40:34 +02:00
Add assertion that DeprecationEntry flag do not have dashes (#16475)
Added a `debug_assert` when using `DeprecationType::Flag` to ensure that the dashes aren't included as part of the flag name. This will hopefully catch something like the issue discovered in #16473 from occurring. ## Release notes summary - What our users need to know N/A --------- Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
@@ -87,7 +87,16 @@ impl DeprecationEntry {
|
||||
fn check(&self, call: &Call) -> bool {
|
||||
match &self.ty {
|
||||
DeprecationType::Command => true,
|
||||
DeprecationType::Flag(flag) => call.get_named_arg(flag).is_some(),
|
||||
DeprecationType::Flag(flag) => {
|
||||
// Make sure we don't accidentally have dashes in the flag
|
||||
debug_assert!(
|
||||
!flag.starts_with('-'),
|
||||
"DeprecationEntry for {} should not include dashes in the flag name!",
|
||||
flag
|
||||
);
|
||||
|
||||
call.get_named_arg(flag).is_some()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user