From 0fa862a2e9b2e41656265dfaa0a4c57a2ab36180 Mon Sep 17 00:00:00 2001 From: Bruno Bigras Date: Mon, 26 Aug 2019 14:09:39 -0400 Subject: [PATCH] make the battery module optional for now (#234) The 'battery' crate doesn't support Termux, so we are temporarily making the battery module optional. --- Cargo.toml | 7 ++++++- src/module.rs | 1 + src/modules/mod.rs | 5 ++++- src/print.rs | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a0da39f2..7bb76abb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,9 @@ is-it-maintained-issue-resolution = { repository = "starship/starship" } is-it-maintained-open-issues = { repository = "starship/starship" } maintenance = { status = "actively-developed" } +[features] +default = ["battery"] + [dependencies] clap = "2.33.0" ansi_term = "0.12.0" @@ -30,7 +33,9 @@ serde_json = "1.0.40" rayon = "1.1.0" pretty_env_logger = "0.3.1" log = "0.4.8" -battery = "0.7.4" +# battery is optional (on by default) because the crate doesn't currently build for Termux +# see: https://github.com/svartalf/rust-battery/issues/33 +battery = { version = "0.7.4", optional = true } lazy_static = "1.4.0" path-slash = "0.1.1" diff --git a/src/module.rs b/src/module.rs index fcb1ea36..55a8199c 100644 --- a/src/module.rs +++ b/src/module.rs @@ -6,6 +6,7 @@ use std::fmt; // List of all modules pub const ALL_MODULES: &[&str] = &[ + #[cfg(feature = "battery")] "battery", "character", "cmd_duration", diff --git a/src/modules/mod.rs b/src/modules/mod.rs index 46929c31..6c6861ef 100644 --- a/src/modules/mod.rs +++ b/src/modules/mod.rs @@ -1,5 +1,4 @@ // While adding out new module add out module to src/module.rs ALL_MODULES const array also. -mod battery; mod character; mod cmd_duration; mod directory; @@ -16,6 +15,9 @@ mod ruby; mod rust; mod username; +#[cfg(feature = "battery")] +mod battery; + use crate::context::Context; use crate::module::Module; @@ -33,6 +35,7 @@ pub fn handle<'a>(module: &str, context: &'a Context) -> Option> { "git_branch" => git_branch::module(context), "git_status" => git_status::module(context), "username" => username::module(context), + #[cfg(feature = "battery")] "battery" => battery::module(context), "cmd_duration" => cmd_duration::module(context), "jobs" => jobs::module(context), diff --git a/src/print.rs b/src/print.rs index 56ba2287..c3d2e8f4 100644 --- a/src/print.rs +++ b/src/print.rs @@ -26,6 +26,7 @@ const DEFAULT_PROMPT_ORDER: &[&str] = &[ "cmd_duration", "line_break", "jobs", + #[cfg(feature = "battery")] "battery", "character", ];