From 80f9590ca2631be69d167a58d296ef1131ee5903 Mon Sep 17 00:00:00 2001 From: ThePerkinrex Date: Thu, 14 Oct 2021 18:52:34 +0200 Subject: [PATCH] feature-gate ANSI frontend to reduce minimal needed dependdencies --- server/Cargo.toml | 9 ++++++--- server/src/logger.rs | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/server/Cargo.toml b/server/Cargo.toml index 6c1ec90..1283715 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -6,6 +6,10 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +default = ["ansi"] +ansi = ["crossterm"] + [dependencies] # Utilities rand = "0.8" @@ -33,11 +37,10 @@ prost = "0.8" prost-types = "0.8" # Database (SQLite) -rusqlite = {version = "0.25", features=["bundled"]} -# sqlx = { version = "0.3", default-features = false, features = [ "runtime-tokio", "macros", "sqlite" ] } +rusqlite = {version = "0.26", features=["bundled"]} # TUI -crossterm = "0.20" +crossterm = {version = "0.21", optional = true} log = "0.4" fern = {version = "0.6", features = ["colored"]} chrono = "0.4" diff --git a/server/src/logger.rs b/server/src/logger.rs index c4dd1c9..65b416d 100644 --- a/server/src/logger.rs +++ b/server/src/logger.rs @@ -1,7 +1,12 @@ use std::sync::mpsc; +#[cfg(feature = "ansi")] mod ansi; +#[cfg(feature = "ansi")] +use ansi::ANSIFrontend; + mod barebones; +use barebones::BarebonesFrontend; use fern::Dispatch; @@ -11,7 +16,6 @@ use crate::{ server_properties::ServerProperties, }; -use self::{ansi::ANSIFrontend, barebones::BarebonesFrontend}; pub type Stdout = mpsc::Sender; pub type Stdin = mpsc::Receiver; @@ -63,9 +67,10 @@ pub fn setup(properties: &ServerProperties) -> anyhow::Result<(Close, Stdin BarebonesFrontend::setup(properties, d), + #[cfg(feature = "ansi")] "ANSI" => ANSIFrontend::setup(properties, d), x => { - println!("Unrecognized logging frontend {}, please select a valid one (barebones, ANSI) from the ones featured on your build, whose list could be smaller than the one shown", x); + println!("Unrecognized logging frontend {}, please select a valid one (barebones, ANSI) from the ones featured on your build, that could have less options than the ones shown", x); Err(anyhow::anyhow!("Unrecognized logging frontend")) } }