2019-09-21 18:53:30 -07:00
|
|
|
use crate::common::*;
|
|
|
|
|
2021-06-08 01:01:27 -07:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2021-03-30 17:30:32 -07:00
|
|
|
pub(crate) enum Warning {
|
2021-03-30 17:59:15 -07:00
|
|
|
// Remove this on 2021-07-01.
|
|
|
|
#[allow(dead_code)]
|
2021-03-30 17:30:32 -07:00
|
|
|
DotenvLoad,
|
|
|
|
}
|
2019-09-21 18:53:30 -07:00
|
|
|
|
2021-03-28 23:39:23 -07:00
|
|
|
impl Warning {
|
|
|
|
fn context(&self) -> Option<&Token> {
|
2021-03-30 17:30:32 -07:00
|
|
|
match self {
|
|
|
|
Self::DotenvLoad => None,
|
|
|
|
}
|
2019-09-21 18:53:30 -07:00
|
|
|
}
|
|
|
|
|
2021-07-26 01:26:06 -07:00
|
|
|
pub(crate) fn write(&self, w: &mut dyn Write, color: Color) -> io::Result<()> {
|
|
|
|
let warning = color.warning();
|
|
|
|
let message = color.message();
|
2019-09-21 18:53:30 -07:00
|
|
|
|
2021-07-26 01:26:06 -07:00
|
|
|
write!(w, "{} {}", warning.paint("warning:"), message.prefix())?;
|
2019-09-21 18:53:30 -07:00
|
|
|
|
2021-03-30 17:30:32 -07:00
|
|
|
match self {
|
|
|
|
Self::DotenvLoad => {
|
|
|
|
#[rustfmt::skip]
|
2021-07-26 01:26:06 -07:00
|
|
|
write!(w, "\
|
2021-03-30 17:30:32 -07:00
|
|
|
A `.env` file was found and loaded, but this behavior will change in the future.
|
|
|
|
To silence this warning and continue loading `.env` files, add:
|
|
|
|
|
|
|
|
set dotenv-load := true
|
|
|
|
|
|
|
|
To silence this warning and stop loading `.env` files, add:
|
|
|
|
|
|
|
|
set dotenv-load := false
|
|
|
|
|
|
|
|
See https://github.com/casey/just/issues/469 for more details.")?;
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-07-26 01:26:06 -07:00
|
|
|
writeln!(w, "{}", message.suffix())?;
|
2019-09-21 18:53:30 -07:00
|
|
|
|
|
|
|
if let Some(token) = self.context() {
|
2021-07-26 01:26:06 -07:00
|
|
|
token.write_context(w, warning)?;
|
2019-09-21 18:53:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|