Skip to content

Commit 9ca2811

Browse files
authored
Merge pull request #16 from spencerwooo:ansi-windows
Enable ANSI colors on supported Windows terminals
2 parents c651129 + 442bb22 commit 9ca2811

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Cargo.toml

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bitsrun"
33
description = "A headless login and logout CLI for 10.0.0.55 at BIT"
4-
version = "0.4.0"
4+
version = "0.5.0"
55
edition = "2021"
66
license = "MIT"
77
homepage = "https://github.com/spencerwooo/bitsrun-rs"
@@ -35,13 +35,14 @@ tabled = { version = "0.14", features = ["color"] }
3535
humansize = "2.1"
3636
chrono-humanize = "0.2"
3737
chrono = "0.4"
38-
log = "0.4.26"
39-
pretty_env_logger = "0.5.0"
38+
log = "0.4"
39+
pretty_env_logger = "0.5"
40+
enable-ansi-support = "0.2"
4041

4142
[profile.release]
4243
strip = "symbols"
4344

4445
[package.metadata.deb]
45-
copyright = "2024 Spencer Woo"
46+
copyright = "2025 Spencer Woo"
4647
maintainer-scripts = "debian/"
4748
systemd-units = { enable = true, start = false }

src/main.rs

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use anyhow::Result;
1111
use clap::Parser;
1212
use cli::ClientArgs;
1313
use cli::StatusArgs;
14+
use enable_ansi_support::enable_ansi_support;
1415
use owo_colors::OwoColorize;
1516
use owo_colors::Stream::Stderr;
1617
use owo_colors::Stream::Stdout;
@@ -37,6 +38,11 @@ async fn main() {
3738
}
3839

3940
async fn cli() -> Result<()> {
41+
// disable ansi colors on non-supported windows terminals
42+
if enable_ansi_support().is_err() {
43+
owo_colors::set_override(false);
44+
}
45+
4046
let args = Arguments::parse();
4147

4248
// reusable http client

0 commit comments

Comments
 (0)