2019-09-21 18:53:30 -07:00
|
|
|
use crate::common::*;
|
|
|
|
|
|
|
|
use Warning::*;
|
|
|
|
|
2019-11-07 10:55:15 -08:00
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub(crate) enum Warning<'src> {
|
|
|
|
DeprecatedEquals { equals: Token<'src> },
|
2019-09-21 18:53:30 -07:00
|
|
|
}
|
|
|
|
|
2019-11-07 10:55:15 -08:00
|
|
|
impl<'src> Warning<'src> {
|
|
|
|
fn context(&self) -> Option<&Token<'src>> {
|
2019-09-21 18:53:30 -07:00
|
|
|
match self {
|
|
|
|
DeprecatedEquals { equals } => Some(equals),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Display for Warning<'_> {
|
|
|
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
|
|
|
let warning = Color::fmt(f).warning();
|
|
|
|
let message = Color::fmt(f).message();
|
|
|
|
|
|
|
|
write!(f, "{} {}", warning.paint("warning:"), message.prefix())?;
|
|
|
|
|
|
|
|
match self {
|
|
|
|
DeprecatedEquals { .. } => {
|
|
|
|
writeln!(
|
|
|
|
f,
|
|
|
|
"`=` in assignments, exports, and aliases is being phased out on favor of `:=`"
|
|
|
|
)?;
|
|
|
|
write!(
|
|
|
|
f,
|
|
|
|
"Please see this issue for more details: https://github.com/casey/just/issues/379"
|
|
|
|
)?;
|
2020-02-10 20:07:06 -08:00
|
|
|
},
|
2019-09-21 18:53:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
write!(f, "{}", message.suffix())?;
|
|
|
|
|
|
|
|
if let Some(token) = self.context() {
|
|
|
|
writeln!(f)?;
|
2019-11-13 19:32:50 -08:00
|
|
|
token.write_context(f, Color::fmt(f).warning())?;
|
2019-09-21 18:53:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|