summaryrefslogtreecommitdiffstats
path: root/src/subcommands/parse_ansi.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/subcommands/parse_ansi.rs')
-rw-r--r--src/subcommands/parse_ansi.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/subcommands/parse_ansi.rs b/src/subcommands/parse_ansi.rs
new file mode 100644
index 00000000..51bebe56
--- /dev/null
+++ b/src/subcommands/parse_ansi.rs
@@ -0,0 +1,20 @@
+use std::io::{self, BufRead};
+
+#[cfg(not(tarpaulin_include))]
+pub fn parse_ansi() -> std::io::Result<()> {
+ use crate::{ansi, style::Style};
+
+ for line in io::stdin().lock().lines() {
+ for (ansi_term_style, s) in ansi::parse_style_sections(
+ &line.unwrap_or_else(|line| panic!("Invalid utf-8: {:?}", line)),
+ ) {
+ let style = Style {
+ ansi_term_style,
+ ..Style::default()
+ };
+ print!("({}){}", style.to_painted_string(), style.paint(s));
+ }
+ println!();
+ }
+ Ok(())
+}