allow to supress the warning about old database version

This commit is contained in:
Abraham Toriz 2021-07-29 11:01:13 -05:00
parent 5dd87616f8
commit 615caab92a
No known key found for this signature in database
GPG Key ID: D5B4A746DB5DD42A
1 changed files with 8 additions and 6 deletions

View File

@ -72,6 +72,7 @@ pub fn time_or_warning<D: Database>(time: DateTime<Utc>, db: &D) -> Result<(Date
/// emits the appropiate warning if the old database format was detected.
pub fn warn_if_needed<E: Write>(err: &mut E, needs_warning: bool) -> Result<()> {
if needs_warning {
if std::env::var_os("TIEMPO_SUPRESS_TIMETRAP_WARNING").is_none() {
writeln!(
err,
"{} You are using the old timetrap format, it is advised that \
@ -79,6 +80,7 @@ pub fn warn_if_needed<E: Write>(err: &mut E, needs_warning: bool) -> Result<()>
Yellow.bold().paint("[WARNING]"),
).map_err(|e| IOError(e))?;
}
}
Ok(())
}