Skip to content

Commit

Permalink
Fixing Windows build: no termion support
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospb19 committed Apr 7, 2021
1 parent df1bc87 commit bb004dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
20 changes: 19 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down Expand Up @@ -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"];
Expand Down

0 comments on commit bb004dc

Please sign in to comment.