From 7a286ec4e25d4d2eff2f04bd7acfa7ff9a1d5a4a Mon Sep 17 00:00:00 2001 From: Schneems Date: Mon, 3 Jun 2024 15:17:53 -0500 Subject: [PATCH 1/4] Add fn important style --- examples/style_guide.rs | 15 +++++---------- src/ansi_escape.rs | 3 +++ src/style.rs | 14 +++++++++++++- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/examples/style_guide.rs b/examples/style_guide.rs index e294fe5..4d370b9 100644 --- a/examples/style_guide.rs +++ b/examples/style_guide.rs @@ -135,16 +135,11 @@ fn main() { "style::details(\"extra information\")".to_string(), "Add specific information at the end of a line i.e. 'Cache cleared (ruby version changed)'".to_string() ], - // vec![ - // fmt::HELP.to_string(), - // "fmt::HELP.to_string()".to_string(), - // "A help prefix, use it in a step or section title".to_string() - // ], - // vec![ - // fmt::DEBUG_INFO.to_string(), - // "fmt::DEBUG_INFO.to_string()".to_string(), - // "A debug prefix, use it in a step or section title".to_string() - // ] + vec![ + style::important("HELP:").to_string(), + "style::important(\"HELP:\").to_string()".to_string(), + "Call attention to individual words, useful when you want to emphasize a prefix but not the whole line.".to_string() + ], ]; table.print(data); diff --git a/src/ansi_escape.rs b/src/ansi_escape.rs index a6a4925..07febc6 100644 --- a/src/ansi_escape.rs +++ b/src/ansi_escape.rs @@ -31,6 +31,7 @@ const RED: &str = "\x1B[0;31m"; const YELLOW: &str = "\x1B[0;33m"; const BOLD_CYAN: &str = "\x1B[1;36m"; const BOLD_PURPLE: &str = "\x1B[1;35m"; +const BOLD_UNDERLINE_CYAN: &str = "\x1B[1;4;36m"; const DIM: &str = "\x1B[2;1m"; // Default color but softer/less vibrant #[derive(Debug)] @@ -40,6 +41,7 @@ pub(crate) enum ANSI { Red, Yellow, BoldCyan, + BoldUnderlineCyan, BoldPurple, } @@ -51,6 +53,7 @@ impl ANSI { ANSI::Yellow => YELLOW, ANSI::BoldCyan => BOLD_CYAN, ANSI::BoldPurple => BOLD_PURPLE, + ANSI::BoldUnderlineCyan => BOLD_UNDERLINE_CYAN, } } } diff --git a/src/style.rs b/src/style.rs index 725a5c5..724aeaf 100644 --- a/src/style.rs +++ b/src/style.rs @@ -4,7 +4,7 @@ use crate::ansi_escape::{self, ANSI}; /// Decorate a URL for the build output. pub fn url(contents: impl AsRef) -> String { - ansi_escape::wrap_ansi_escape_each_line(&ANSI::BoldCyan, contents) + ansi_escape::wrap_ansi_escape_each_line(&ANSI::BoldUnderlineCyan, contents) } /// Decorate the name of a command being run i.e. `bundle install`. @@ -26,3 +26,15 @@ pub fn details(contents: impl AsRef) -> String { let contents = contents.as_ref(); format!("({contents})") } + +/// Decorate important information. +/// +/// ``` +/// use bullet_stream::style; +/// +/// let help = style::important("HELP:"); +/// format!("{help} review the logs"); +/// ``` +pub fn important(contents: impl AsRef) -> String { + ansi_escape::wrap_ansi_escape_each_line(&ANSI::BoldCyan, contents) +} From b09ffa2824b54344c6d85d70d5a6b7238e7b0f62 Mon Sep 17 00:00:00 2001 From: Schneems Date: Mon, 3 Jun 2024 15:20:22 -0500 Subject: [PATCH 2/4] Add changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..74884e9 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# CHANGELOG + +## Unreleased + +## v0.0.1 - 2024/06/03 + +- First From 2e0e0c3ff7db42c7548d528b16f3942c13af142c Mon Sep 17 00:00:00 2001 From: Schneems Date: Mon, 3 Jun 2024 15:25:42 -0500 Subject: [PATCH 3/4] Fix docs --- src/lib.rs | 10 +++++----- src/write.rs | 24 ------------------------ 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d812b4c..0c9f391 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -174,7 +174,7 @@ pub mod state { /// This state is intended for long-running tasks that do not stream but wish to convey progress /// to the end user. For example, while downloading a file. /// - /// This state is started from a [`state::SubBullet`] and finished back to a [`state::SubBullet`]. + /// This state is started from a [`SubBullet`] and finished back to a [`SubBullet`]. /// /// ```rust /// use bullet_stream::{Output, state::{Bullet, SubBullet}}; @@ -277,7 +277,7 @@ where /// [`Output::error`] instead. /// /// Warnings will be output in a multi-line paragraph style. A warning can be emitted from any - /// state except for [`state::NotStarted`]. + /// state except for [`state::Header`]. #[must_use] pub fn warning(mut self, s: impl AsRef) -> Output { self.write_paragraph(&ANSI::Yellow, s); @@ -334,7 +334,7 @@ where { /// Create a buildpack output struct, but do not announce the buildpack's start. /// - /// See the [`Output::start`] method for more details. + /// See the [`Output::h1`] and [`Output::h2`] methods for more details. #[must_use] pub fn new(io: W) -> Self { Self { @@ -478,7 +478,7 @@ where /// Finalize a timer's output. /// /// Once you're finished with your long running task, calling this function - /// finalizes the timer's output and transitions back to a [`state::Section`]. + /// finalizes the timer's output and transitions back to a [`state::SubBullet`]. #[must_use] pub fn done(self) -> Output> { let duration = self.state.started.elapsed(); @@ -531,7 +531,7 @@ where /// observable by the user through the buildpack output. For example, if a cache needs to be /// cleared, emit that your buildpack is clearing it and why. /// - /// Multiple steps are allowed within a section. This function returns to the same [`state::Section`]. + /// Multiple steps are allowed within a section. This function returns to the same [`state::SubBullet`]. #[must_use] pub fn sub_bullet(mut self, s: impl AsRef) -> Output> { writeln_now(&mut self.state.write, Self::style(s)); diff --git a/src/write.rs b/src/write.rs index ee67191..51c3a06 100644 --- a/src/write.rs +++ b/src/write.rs @@ -6,8 +6,6 @@ use std::sync::Arc; /// Constructs a writer that buffers written data until given marker byte is encountered and /// then applies the given mapping function to the data before passing the result to the wrapped /// writer. -/// -/// See the [`mappers`] module for a collection of commonly used mappers. pub fn mapped) -> Vec) + Sync + Send + 'static>( w: W, marker_byte: u8, @@ -19,8 +17,6 @@ pub fn mapped) -> Vec) + Sync + Send + 'static> /// Constructs a writer that buffers written data until an ASCII/UTF-8 newline byte (`b'\n'`) is /// encountered and then applies the given mapping function to the data before passing the result to /// the wrapped writer. -/// -/// See the [`mappers`] module for a collection of commonly used mappers. pub fn line_mapped) -> Vec) + Sync + Send + 'static>( w: W, f: F, @@ -47,13 +43,6 @@ pub struct MappedWrite { mapping_fn: Arc) -> Vec) + Sync + Send>, } -/// A tee writer that was created with the [`tee`] function. -#[derive(Debug, Clone)] -pub struct TeeWrite { - inner_a: A, - inner_b: B, -} - impl MappedWrite where W: io::Write, @@ -134,19 +123,6 @@ impl Debug for MappedWrite { } } -impl io::Write for TeeWrite { - fn write(&mut self, buf: &[u8]) -> io::Result { - self.inner_a.write_all(buf)?; - self.inner_b.write_all(buf)?; - Ok(buf.len()) - } - - fn flush(&mut self) -> io::Result<()> { - self.inner_a.flush()?; - self.inner_b.flush() - } -} - #[cfg(test)] mod test { use crate::write::line_mapped; From 371f296bf7bec2844caef639980a58011b503ec6 Mon Sep 17 00:00:00 2001 From: Schneems Date: Mon, 3 Jun 2024 15:26:24 -0500 Subject: [PATCH 4/4] Fix version in CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74884e9..4f99696 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,6 @@ ## Unreleased -## v0.0.1 - 2024/06/03 +## v0.1.0 - 2024/06/03 - First