From 87eca1a0d02bb711b531e2152153ee2304a7bef3 Mon Sep 17 00:00:00 2001 From: Denis Isidoro Date: Sat, 29 Aug 2020 15:53:28 -0300 Subject: [PATCH] Notify deprecation at most once (#393) --- src/structures/config.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/structures/config.rs b/src/structures/config.rs index 8901bd1..ea7759e 100644 --- a/src/structures/config.rs +++ b/src/structures/config.rs @@ -2,6 +2,8 @@ use crate::finder::FinderChoice; use anyhow::Error; use structopt::{clap::AppSettings, StructOpt}; +static mut NOTIFIED_DEPRECATION: bool = false; + fn parse_finder(src: &str) -> Result { match src { "fzf" => Ok(FinderChoice::Fzf), @@ -153,15 +155,22 @@ pub enum AlfredCommand { } fn deprecated(syntax: &str) { - eprintln!( - r"Warning: the following syntax has been DEPRECATED: + unsafe { + if NOTIFIED_DEPRECATION { + return; + } + eprintln!( + r"⚠️ The following syntax has been DEPRECATED: navi {} -Please check navi --help for more info on how to achieve the same result with the new syntax. +Please check `navi --help` for more info on how to achieve the same result with the new syntax. -The deprecated syntax will be removed in the first version released on 2021!", - syntax - ); +The deprecated syntax will be removed in the first version released on 2021! ⚠️ +", + syntax + ); + NOTIFIED_DEPRECATION = true; + } } pub enum Source {