Skip to content

Commit bee75ca

Browse files
committed
refactor: use colored directly instead of stripping color with a regex
1 parent 062fd6f commit bee75ca

3 files changed

Lines changed: 3 additions & 6 deletions

File tree

‎Cargo.lock‎

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/tower-cmd/Cargo.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ http = { workspace = true }
1818
indicatif = { workspace = true }
1919
promptly = { workspace = true }
2020
reqwest = { workspace = true }
21-
regex = "1.0"
2221
reqwest-eventsource = { workspace = true }
2322
rpassword = { workspace = true }
2423
rsa = { workspace = true }

‎crates/tower-cmd/src/output.rs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use cli_table::{
33
format::{Border, HorizontalLine, Separator},
44
print_stdout, Table,
55
};
6-
use colored::Colorize;
6+
use colored::{control, Colorize};
77
use http::StatusCode;
8-
use regex::Regex;
98
use std::io::{self, Write};
109
use std::sync::{Mutex, OnceLock};
1110
use tokio::sync::mpsc::UnboundedSender;
@@ -22,6 +21,7 @@ static CURRENT_SENDER: Mutex<Option<UnboundedSender<String>>> = Mutex::new(None)
2221

2322
pub fn set_capture_mode() {
2423
CAPTURE_MODE.set(true).ok();
24+
control::set_override(false);
2525
}
2626

2727
pub fn is_capture_mode_set() -> bool {
@@ -132,8 +132,7 @@ pub fn config_error(err: config::Error) {
132132

133133
pub fn write(msg: &str) {
134134
if is_capture_mode_set() {
135-
let re = Regex::new(r"\x1b\[[0-9;]*m").unwrap();
136-
let clean_msg = re.replace_all(msg, "").trim_end().to_string();
135+
let clean_msg = msg.trim_end().to_string();
137136
send_to_current_sender(clean_msg);
138137
} else {
139138
io::stdout().write_all(msg.as_bytes()).unwrap();

0 commit comments

Comments
 (0)