1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-06-10 20:32:21 +00:00

make the battery module optional for now (#234)

The 'battery' crate doesn't support Termux, so we are temporarily making the battery module optional.
This commit is contained in:
Bruno Bigras 2019-08-26 14:09:39 -04:00 committed by Matan Kushner
parent f7754455e6
commit 0fa862a2e9
4 changed files with 12 additions and 2 deletions

View File

@ -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"

View File

@ -6,6 +6,7 @@ use std::fmt;
// List of all modules
pub const ALL_MODULES: &[&str] = &[
#[cfg(feature = "battery")]
"battery",
"character",
"cmd_duration",

View File

@ -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<Module<'a>> {
"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),

View File

@ -26,6 +26,7 @@ const DEFAULT_PROMPT_ORDER: &[&str] = &[
"cmd_duration",
"line_break",
"jobs",
#[cfg(feature = "battery")]
"battery",
"character",
];