summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhspetersson <jhspetersson@gmail.com>2023-09-26 09:25:18 +0200
committerjhspetersson <jhspetersson@gmail.com>2023-09-26 09:25:18 +0200
commit2bd38d5c5327d038e664a539cdf8108ddb029893 (patch)
treef352d3affdde2b7f114adf26d0d69b8643bf29f0
parentcf418ef5877c520d2f23062c87119484df2bd7c2 (diff)
make update notifications an optional feature
-rw-r--r--Cargo.toml5
-rw-r--r--src/main.rs21
2 files changed, 16 insertions, 10 deletions
diff --git a/Cargo.toml b/Cargo.toml
index a40cbac..cfe81f2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,8 @@ license = "MIT/Apache-2.0"
edition = "2021"
[features]
-default = ["users"]
+default = ["users", "update-notifications"]
+update-notifications = ["dep:update-informer"]
[dependencies]
bytecount = "0.6"
@@ -43,7 +44,7 @@ sha3 = "0.10"
svg = "0.13"
toml = "0.8"
tree_magic_mini = { version = "3.0", features = [ "tree_magic_db" ] }
-update-informer = "1.1.0"
+update-informer = { version = "1.1.0", optional = true }
wana_kana = "3.0"
zip = "0.6"
diff --git a/src/main.rs b/src/main.rs
index 1a823e4..51a0f32 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,11 +11,13 @@ use std::env;
use std::io::{IsTerminal, stdout};
use std::path::PathBuf;
use std::process::ExitCode;
+#[cfg(feature = "update-notifications")]
use std::time::Duration;
use nu_ansi_term::Color::*;
use rustyline::error::ReadlineError;
use rustyline::DefaultEditor;
+#[cfg(feature = "update-notifications")]
use update_informer::{registry, Check};
mod config;
@@ -163,16 +165,19 @@ fn main() -> ExitCode {
config.save();
- if let Some(exit_value) = exit_value {
- return ExitCode::from(exit_value);
- }
+ #[cfg(feature = "update-notifications")]
+ if stdout().is_terminal() {
+ let name = env!("CARGO_PKG_NAME");
+ let version = env!("CARGO_PKG_VERSION");
+ let informer = update_informer::new(registry::Crates, name, version).interval(Duration::from_secs(60 * 60));
- let name = env!("CARGO_PKG_NAME");
- let version = env!("CARGO_PKG_VERSION");
- let informer = update_informer::new(registry::Crates, name, version).interval(Duration::from_secs(60 * 60));
+ if let Some(version) = informer.check_version().ok().flatten() {
+ println!("\nNew version is available! : {}", version);
+ }
+ }
- if let Some(version) = informer.check_version().ok().flatten() {
- println!("\n A New version is available! : {}", version);
+ if let Some(exit_value) = exit_value {
+ return ExitCode::from(exit_value);
}
ExitCode::SUCCESS