Repository: nushell/nushell
File: crates/nu-protocol/src/deprecation.rs (Rust)

Code before:
            });
        };
        match val.as_str() {
            "first" => Ok(ReportMode::FirstUse),
            "every" => Ok(ReportMode::EveryUse),
            _ => Err(ShellError::InvalidValue {
                valid: "first or every".into(),
                actual: val,
                span,
            }),
        }
    }

    fn expected_type() -> Type {
        Type::String
    }
}

impl DeprecationEntry {
    fn check(&self, call: &Call) -> bool {
        match &self.ty {
            DeprecationType::Command => true,
            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()
            }
        }
    }

    fn type_name(&self) -> String {
        match &self.ty {
            DeprecationType::Command => "Command".to_string(),
            DeprecationType::Flag(_) => "Flag".to_string(),
        }
    }

    fn label(&self, command_name: &str) -> String {
        let name = match &self.ty {
            DeprecationType::Command => command_name,
            DeprecationType::Flag(flag) => &format!("{command_name} --{flag}"),
        };
        let since = match &self.since {
            Some(since) => format!("was deprecated in {since}"),
            None => "is deprecated".to_string(),
        };

Review comment (suggestion):
Being defensive ;)

```suggestion
                    !flag.starts_with('-'),
```

Code after:
            });
        };
        match val.as_str() {
            "first" => Ok(ReportMode::FirstUse),
            "every" => Ok(ReportMode::EveryUse),
            _ => Err(ShellError::InvalidValue {
                valid: "first or every".into(),
                actual: val,
                span,
            }),
        }
    }

    fn expected_type() -> Type {
        Type::String
    }
}

impl DeprecationEntry {
    fn check(&self, call: &Call) -> bool {
        match &self.ty {
            DeprecationType::Command => true,
            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()
            }
        }
    }

    fn type_name(&self) -> String {
        match &self.ty {
            DeprecationType::Command => "Command".to_string(),
            DeprecationType::Flag(_) => "Flag".to_string(),
        }
    }

    fn label(&self, command_name: &str) -> String {
        let name = match &self.ty {
            DeprecationType::Command => command_name,
            DeprecationType::Flag(flag) => &format!("{command_name} --{flag}"),
        };
        let since = match &self.since {
            Some(since) => format!("was deprecated in {since}"),
            None => "is deprecated".to_string(),
        };