mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-30 09:05:54 +00:00
Replace is-terminal with supports-color and make auto default for color
This commit is contained in:
1 parent
c7e2235293
commit
5bd76fd11b
2 files changed
+6
-6
No files matched your search
+1
-1
@@ -14,8 +14,8 @@ edition = "2021"
|
|||||||
anstyle = "0.2"
|
anstyle = "0.2"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
const_format = "0.2"
|
const_format = "0.2"
|
||||||
is-terminal = "0.4"
|
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
|
supports-color = "1"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
terminal_size = "0.2"
|
terminal_size = "0.2"
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -9,8 +9,6 @@ use std::num::{NonZeroI64, NonZeroU64, NonZeroU8};
|
|||||||
use clap::builder::ArgPredicate;
|
use clap::builder::ArgPredicate;
|
||||||
use clap::{crate_name, crate_version, Arg, ArgAction, ColorChoice, Command};
|
use clap::{crate_name, crate_version, Arg, ArgAction, ColorChoice, Command};
|
||||||
|
|
||||||
use is_terminal::IsTerminal;
|
|
||||||
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
|
|
||||||
use const_format::formatcp;
|
use const_format::formatcp;
|
||||||
@@ -106,7 +104,7 @@ fn run() -> Result<()> {
|
|||||||
.value_name("WHEN")
|
.value_name("WHEN")
|
||||||
.value_parser(["always", "auto", "never"])
|
.value_parser(["always", "auto", "never"])
|
||||||
.default_value_if("plain", ArgPredicate::IsPresent, Some("never"))
|
.default_value_if("plain", ArgPredicate::IsPresent, Some("never"))
|
||||||
.default_value("always")
|
.default_value("auto")
|
||||||
.help(
|
.help(
|
||||||
"When to use colors. The auto-mode only displays colors if the output \
|
"When to use colors. The auto-mode only displays colors if the output \
|
||||||
goes to an interactive terminal",
|
goes to an interactive terminal",
|
||||||
@@ -293,8 +291,10 @@ fn run() -> Result<()> {
|
|||||||
|
|
||||||
let show_color = match matches.get_one::<String>("color").map(String::as_ref) {
|
let show_color = match matches.get_one::<String>("color").map(String::as_ref) {
|
||||||
Some("never") => false,
|
Some("never") => false,
|
||||||
Some("auto") => std::io::stdout().is_terminal(),
|
Some("always") => true,
|
||||||
_ => true,
|
_ => supports_color::on_cached(supports_color::Stream::Stdout)
|
||||||
|
.map(|level| level.has_basic)
|
||||||
|
.unwrap_or(false),
|
||||||
};
|
};
|
||||||
|
|
||||||
let border_style = match matches.get_one::<String>("border").map(String::as_ref) {
|
let border_style = match matches.get_one::<String>("border").map(String::as_ref) {
|
||||||
|
|||||||
Reference in new issue
Block a user