mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
Respect the NO_COLOR
env. arg.
This commit is contained in:
parent
55aa65dcea
commit
b099e4ac20
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -104,6 +104,12 @@ dependencies = [
|
|||||||
"wasi",
|
"wasi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazy_static"
|
||||||
|
version = "1.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.98"
|
version = "0.2.98"
|
||||||
@ -148,6 +154,7 @@ version = "0.1.6"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bzip2",
|
"bzip2",
|
||||||
"flate2",
|
"flate2",
|
||||||
|
"lazy_static",
|
||||||
"rand",
|
"rand",
|
||||||
"strsim",
|
"strsim",
|
||||||
"tar",
|
"tar",
|
||||||
|
15
Cargo.toml
15
Cargo.toml
@ -13,13 +13,14 @@ description = "A command-line utility for easily compressing and decompressing f
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
walkdir = "2.3.2"
|
walkdir = "2.3.2"
|
||||||
strsim = "0.10.0"
|
strsim = "0.10.0"
|
||||||
flate2 = { version = "1.0.22", default-features = false, features = ["zlib"] }
|
flate2 = { version = "1.0.22", default-features = false, features = ["zlib"] }
|
||||||
bzip2 = "0.4.3"
|
bzip2 = "0.4.3"
|
||||||
tar = "0.4.37"
|
tar = "0.4.37"
|
||||||
xz2 = "0.1.6"
|
xz2 = "0.1.6"
|
||||||
zip = { version = "0.5.13", default-features = false, features = ["deflate-miniz"] }
|
zip = { version = "0.5.13", default-features = false, features = ["deflate-miniz"] }
|
||||||
|
lazy_static = "1.4.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3.2.0"
|
tempfile = "3.2.0"
|
||||||
|
10
src/lib.rs
10
src/lib.rs
@ -13,10 +13,20 @@ mod utils;
|
|||||||
|
|
||||||
pub use error::{Error, Result};
|
pub use error::{Error, Result};
|
||||||
|
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
pub const EXIT_FAILURE: i32 = 127;
|
pub const EXIT_FAILURE: i32 = 127;
|
||||||
|
|
||||||
const VERSION: &str = "0.1.5";
|
const VERSION: &str = "0.1.5";
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref NO_COLOR_IS_SET: bool = {
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
env::var("NO_COLOR").is_ok()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
fn help_command() {
|
fn help_command() {
|
||||||
use utils::colors::*;
|
use utils::colors::*;
|
||||||
/*
|
/*
|
||||||
|
@ -1,13 +1,25 @@
|
|||||||
|
use crate::NO_COLOR_IS_SET;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! info {
|
macro_rules! info {
|
||||||
|
|
||||||
($writer:expr, $($arg:tt)*) => {
|
($writer:expr, $($arg:tt)*) => {
|
||||||
use crate::utils::colors::{reset, yellow};
|
use crate::macros::_info_helper;
|
||||||
print!("{}[INFO]{} ", yellow(), reset());
|
_info_helper();
|
||||||
println!($writer, $($arg)*);
|
println!($writer, $($arg)*);
|
||||||
};
|
};
|
||||||
($writer:expr) => {
|
($writer:expr) => {
|
||||||
print!("{}[INFO]{} ", yellow(), reset());
|
_info_helper();
|
||||||
println!($writer);
|
println!($writer);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn _info_helper() {
|
||||||
|
use crate::utils::colors::{reset, yellow};
|
||||||
|
|
||||||
|
if *NO_COLOR_IS_SET {
|
||||||
|
print!("[INFO] ");
|
||||||
|
} else {
|
||||||
|
print!("{}[INFO]{} ", yellow(), reset());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -10,7 +10,7 @@ use crate::{dialogs::Confirmation, info, oof};
|
|||||||
pub fn create_dir_if_non_existent(path: &Path) -> crate::Result<()> {
|
pub fn create_dir_if_non_existent(path: &Path) -> crate::Result<()> {
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
fs::create_dir_all(path)?;
|
fs::create_dir_all(path)?;
|
||||||
info!("directory {:#?} created.", to_utf(path));
|
info!("directory {} created.", to_utf(path));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user