Fixing Windows build: no termion support

This commit is contained in:
João M. Bezerra 2021-04-06 23:06:53 -03:00
parent df1bc879cb
commit bb004dc78c
2 changed files with 21 additions and 2 deletions

View File

@ -14,7 +14,6 @@ description = "A command-line utility for easily compressing and decompressing f
[dependencies]
colored = "2.0.0"
termion = "1.5.6"
walkdir = "2.3.2"
tar = "0.4.33"
xz2 = "0.1.6"
@ -25,6 +24,8 @@ zip = "0.5.11"
# Dependency from workspace
oof = { path = "./oof" }
[target.'cfg(unix)'.dependencies]
termion = "1.5.6"
[profile.release]
lto = true
codegen-units = 1

View File

@ -126,7 +126,9 @@ pub struct Bytes {
bytes: f64,
}
#[allow(dead_code)]
/// Module with a list of bright colors.
#[allow(dead_code, non_upper_case_globals)]
#[cfg(target_family = "unix")]
pub mod colors {
use termion::color::*;
@ -158,6 +160,22 @@ pub mod colors {
LightYellow.fg_str()
}
}
// Termion does not support Windows
#[cfg(not(target_family = "unix"))]
pub mod colors {
pub fn empty() -> &'static str {
""
}
pub const reset: fn() -> &'static str = empty;
pub const black: fn() -> &'static str = empty;
pub const blue: fn() -> &'static str = empty;
pub const cyan: fn() -> &'static str = empty;
pub const green: fn() -> &'static str = empty;
pub const magenta: fn() -> &'static str = empty;
pub const red: fn() -> &'static str = empty;
pub const white: fn() -> &'static str = empty;
pub const yellow: fn() -> &'static str = empty;
}
impl Bytes {
const UNIT_PREFIXES: [&'static str; 6] = ["", "k", "M", "G", "T", "P"];