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 {
|
|
|
|
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-28 18:06:57 -07:00
|
|
|
}
|
2019-09-21 18:53:30 -07:00
|
|
|
|
2021-07-28 18:06:57 -07:00
|
|
|
impl ColorDisplay for Warning {
|
|
|
|
fn fmt(&self, f: &mut Formatter, color: Color) -> fmt::Result {
|
2021-07-26 01:26:06 -07:00
|
|
|
let warning = color.warning();
|
|
|
|
let message = color.message();
|
2019-09-21 18:53:30 -07:00
|
|
|
|
2021-07-28 18:06:57 -07:00
|
|
|
write!(f, "{} {}", 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-28 18:06:57 -07:00
|
|
|
write!(f, "\
|
2021-03-30 17:30:32 -07:00
|
|
|
A `.env` file was found and loaded, but this behavior will change in the future.
|
2021-07-28 00:33:44 -07:00
|
|
|
|
2021-03-30 17:30:32 -07:00
|
|
|
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
|
|
|
|
|
2021-07-28 00:33:44 -07:00
|
|
|
This warning may also be silenced by setting the `JUST_SUPPRESS_DOTENV_LOAD_WARNING`
|
|
|
|
environment variable to `1`. This can be used to silence the warning globally by
|
|
|
|
adding the following line to your shell rc file:
|
|
|
|
|
|
|
|
export JUST_SUPPRESS_DOTENV_LOAD_WARNING=1
|
|
|
|
|
2021-03-30 17:30:32 -07:00
|
|
|
See https://github.com/casey/just/issues/469 for more details.")?;
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-07-28 18:06:57 -07:00
|
|
|
write!(f, "{}", message.suffix())?;
|
2019-09-21 18:53:30 -07:00
|
|
|
|
|
|
|
if let Some(token) = self.context() {
|
2021-07-28 18:06:57 -07:00
|
|
|
writeln!(f)?;
|
|
|
|
write!(f, "{}", token.color_display(color))?;
|
2019-09-21 18:53:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|