Skip to content

Commit

Permalink
release: 0.13.6
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed May 27, 2024
2 parents 2178b92 + 49e0264 commit cd9ce56
Show file tree
Hide file tree
Showing 20 changed files with 101 additions and 116 deletions.
8 changes: 4 additions & 4 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Project Dependencies
Package: fyi
Version: 0.13.5
Generated: 2024-05-19 04:33:40 UTC
Version: 0.13.6
Generated: 2024-05-27 17:54:01 UTC

| Package | Version | Author(s) | License |
| ---- | ---- | ---- | ---- |
| [argyle](https://github.com/Blobfolio/argyle) | 0.7.2 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [const_fn](https://github.com/taiki-e/const_fn) | 0.4.10 | | Apache-2.0 or MIT |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.13.5 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.13.6 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [tz-rs](https://github.com/x-hgg-x/tz-rs) | 0.6.14 | x-hgg-x | Apache-2.0 or MIT |
| [utc2k](https://github.com/Blobfolio/utc2k) | 0.8.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
2 changes: 1 addition & 1 deletion fyi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fyi"
version = "0.13.5"
version = "0.13.6"
license = "WTFPL"
authors = ["Blobfolio, LLC. <[email protected]>"]
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion fyi_msg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fyi_msg"
version = "0.13.5"
version = "0.13.6"
authors = ["Blobfolio, LLC. <[email protected]>"]
edition = "2021"
rust-version = "1.72"
Expand Down
56 changes: 23 additions & 33 deletions fyi_msg/src/msg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,18 +309,14 @@ impl Msg {
/// ```
pub fn new<S>(kind: MsgKind, msg: S) -> Self
where S: AsRef<str> {
fn build(kind: MsgKind, msg: &str) -> Msg {
let msg = msg.as_bytes();
let p_end = kind.len_32();
let m_end = p_end + msg.len() as u32;

Msg(MsgBuffer::from_raw_parts(
[kind.as_bytes(), msg].concat(),
new_toc!(p_end, m_end)
))
}
let msg = msg.as_ref().as_bytes();
let p_end = kind.len_32();
let m_end = p_end + msg.len() as u32;

build(kind, msg.as_ref())
Self(MsgBuffer::from_raw_parts(
[kind.as_bytes(), msg].concat(),
new_toc!(p_end, m_end)
))
}

#[allow(clippy::cast_possible_truncation)] // MsgBuffer checks fit.
Expand All @@ -343,30 +339,24 @@ impl Msg {
/// ```
pub fn custom<S>(prefix: S, color: u8, msg: S) -> Self
where S: AsRef<str> {
fn build(prefix: &str, color: u8, msg: &str) -> Msg {
let prefix = prefix.as_bytes();
if prefix.is_empty() {
return Msg::plain(msg);
}
let prefix = prefix.as_ref().as_bytes();
if prefix.is_empty() { return Self::plain(msg); }

// Start a vector with the prefix bits.
let msg = msg.as_bytes();
let v = [
b"\x1b[1;38;5;",
&*NiceU8::from(color),
b"m",
prefix,
b":\x1b[0m ",
msg,
].concat();

let m_end = v.len() as u32;
let p_end = m_end - msg.len() as u32;

Msg(MsgBuffer::from_raw_parts(v, new_toc!(p_end, m_end)))
}
// Start a vector with the prefix bits.
let msg = msg.as_ref().as_bytes();
let v = [
b"\x1b[1;38;5;",
&*NiceU8::from(color),
b"m",
prefix,
b":\x1b[0m ",
msg,
].concat();

let m_end = v.len() as u32;
let p_end = m_end - msg.len() as u32;

build(prefix.as_ref(), color, msg.as_ref())
Self(MsgBuffer::from_raw_parts(v, new_toc!(p_end, m_end)))
}

#[allow(clippy::cast_possible_truncation)] // MsgBuffer checks fit.
Expand Down
43 changes: 24 additions & 19 deletions fyi_msg/src/progress/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,10 @@ impl ProglessInner {
/// The progress bar can optionally keep track of tasks that are actively
/// "in progress", which can be particularly useful when operating in
/// parallel.
///
/// Any `AsRef<str>` value will do. See the module documentation for
/// example usage.
fn add<S>(&self, txt: S)
where S: AsRef<str> {
fn add(&self, txt: &str) {
if
self.running() &&
ProglessTask::new(txt.as_ref()).is_some_and(|m| mutex!(self.doing).insert(m))
ProglessTask::new(txt).is_some_and(|m| mutex!(self.doing).insert(m))
{
self.flags.fetch_or(TICK_DOING, SeqCst);
}
Expand Down Expand Up @@ -384,11 +380,10 @@ impl ProglessInner {
/// Note: This will add a `\n` to the end of the string.
///
/// The message will be printed to STDERR if `stderr`, otherwise STDOUT.
fn push_msg<S>(&self, msg: S, stderr: bool)
where S: Into<Msg> {
fn push_msg(&self, msg: Msg, stderr: bool) {
self.print_cls();

let msg = msg.into().with_newline(true);
let msg = msg.with_newline(true);
if stderr { msg.eprint(); }
else { msg.print(); }

Expand All @@ -400,8 +395,7 @@ impl ProglessInner {
/// This is the equal and opposite companion to `add`. Calling this will
/// automatically increment the done count by one, so should not be used
/// in cases where you're triggering done changes manually.
fn remove<S>(&self, txt: S)
where S: AsRef<str> {
fn remove(&self, txt: &str) {
if self.running() {
if let Some(txt) = ProglessTask::fmt(txt) {
if mutex!(self.doing).remove(txt.as_bytes()) {
Expand Down Expand Up @@ -457,10 +451,9 @@ impl ProglessInner {
/// Give the progress bar a title, which will be shown above the progress
/// bits while progress is progressing, and removed afterward with
/// everything else.
fn set_title<S>(&self, title: Option<S>)
where S: Into<Msg> {
fn set_title(&self, title: Option<Msg>) {
if self.running() {
if let Some(title) = title.map(Into::into).filter(|x| ! x.is_empty()) {
if let Some(title) = title {
mutex!(self.title).replace(title.with_newline(true));
}
else {
Expand Down Expand Up @@ -1034,6 +1027,11 @@ impl Progless {
/// ```
pub fn with_title<S>(self, title: Option<S>) -> Self
where S: Into<Msg> {
let title = title.and_then(|m| {
let m = m.into();
if m.is_empty() { None }
else { Some(m) }
});
self.inner.set_title(title);
self
}
Expand Down Expand Up @@ -1127,7 +1125,7 @@ impl Progless {
pub fn summary<S>(&self, kind: MsgKind, singular: S, plural: S) -> Msg
where S: AsRef<str> {
Msg::new(kind, [
&self.inner.done().nice_inflect(singular, plural),
&self.inner.done().nice_inflect(singular.as_ref(), plural.as_ref()),
" in ",
NiceElapsed::from(self.inner.started).as_str(),
".",
Expand Down Expand Up @@ -1169,7 +1167,7 @@ impl Progless {
/// pbar.finish();
/// ```
pub fn add<S>(&self, txt: S)
where S: AsRef<str> { self.inner.add(txt); }
where S: AsRef<str> { self.inner.add(txt.as_ref()); }

#[inline]
/// # Increment Done.
Expand Down Expand Up @@ -1199,7 +1197,7 @@ impl Progless {
///
/// The message will be printed to STDERR if `stderr`, otherwise STDOUT.
pub fn push_msg<S>(&self, msg: S, stderr: bool)
where S: Into<Msg> { self.inner.push_msg(msg, stderr); }
where S: Into<Msg> { self.inner.push_msg(msg.into(), stderr); }

#[inline]
/// # Remove a task.
Expand All @@ -1211,7 +1209,7 @@ impl Progless {
/// See [`Progless::add`] for more details. If you use one, you must use
/// both.
pub fn remove<S>(&self, txt: S)
where S: AsRef<str> { self.inner.remove(txt); }
where S: AsRef<str> { self.inner.remove(txt.as_ref()); }

/// # Reset.
///
Expand Down Expand Up @@ -1256,7 +1254,14 @@ impl Progless {
///
/// See [`Progless::with_title`] for more details.
pub fn set_title<S>(&self, title: Option<S>)
where S: Into<Msg> { self.inner.set_title(title); }
where S: Into<Msg> {
let title = title.and_then(|m| {
let m = m.into();
if m.is_empty() { None }
else { Some(m) }
});
self.inner.set_title(title);
}

#[inline]
/// # Set Title As X: Reticulating Splines…
Expand Down
50 changes: 20 additions & 30 deletions fyi_msg/src/progress/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,17 @@ impl ProglessTask {
/// Create a new task from raw bytes.
///
/// This will return `None` if the source is empty or larger than `u16`.
pub(super) fn new<S>(src: S) -> Option<Self>
where S: AsRef<str> {
fn build(src: &str) -> Option<ProglessTask> {
let inner = ProglessTask::fmt(src)?.into_bytes();
let width = u16::try_from(fitted::width(&inner)).ok()?;

if width != 0 {
Some(ProglessTask {
inner: inner.into_boxed_slice(),
width
})
}
else { None }
pub(super) fn new(src: &str) -> Option<Self> {
let inner = Self::fmt(src)?.into_bytes();
let width = u16::try_from(fitted::width(&inner)).ok()?;

if width != 0 {
Some(Self {
inner: inner.into_boxed_slice(),
width
})
}

build(src.as_ref())
else { None }
}

/// # Format String.
Expand All @@ -85,21 +80,16 @@ impl ProglessTask {
/// lines to spaces to improve display consistency.
///
/// If the result is empty, `None` is returned.
pub(super) fn fmt<S>(src: S) -> Option<String>
where S: AsRef<str> {
fn build(src: &str) -> Option<String> {
let out = NoAnsi::<char, _>::new(src.trim_end().chars())
.filter_map(|c|
if c == '\n' { Some(' ') }
else if c.is_control() { None }
else { Some(c) }
)
.collect::<String>();
if out.is_empty() { None }
else { Some(out) }
}

build(src.as_ref())
pub(super) fn fmt(src: &str) -> Option<String> {
let out = NoAnsi::<char, _>::new(src.trim_end().chars())
.filter_map(|c|
if c == '\n' { Some(' ') }
else if c.is_control() { None }
else { Some(c) }
)
.collect::<String>();
if out.is_empty() { None }
else { Some(out) }
}

/// # Push To.
Expand Down
4 changes: 2 additions & 2 deletions release/man/fyi-blank.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "FYI BLANK" "1" "May 2024" "blank v0.13.5" "User Commands"
.TH "FYI BLANK" "1" "May 2024" "blank v0.13.6" "User Commands"
.SH NAME
blank \- Manual page for blank v0.13.5.
blank \- Manual page for blank v0.13.6.
.SH DESCRIPTION
Print blank line(s).
.SS USAGE:
Expand Down
4 changes: 2 additions & 2 deletions release/man/fyi-confirm.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "FYI CONFIRM" "1" "May 2024" "confirm v0.13.5" "User Commands"
.TH "FYI CONFIRM" "1" "May 2024" "confirm v0.13.6" "User Commands"
.SH NAME
confirm \- Manual page for confirm v0.13.5.
confirm \- Manual page for confirm v0.13.6.
.SH DESCRIPTION
Ask a Yes/No question using the built\-in prefix "confirm".
.SS USAGE:
Expand Down
4 changes: 2 additions & 2 deletions release/man/fyi-crunched.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "FYI CRUNCHED" "1" "May 2024" "crunched v0.13.5" "User Commands"
.TH "FYI CRUNCHED" "1" "May 2024" "crunched v0.13.6" "User Commands"
.SH NAME
crunched \- Manual page for crunched v0.13.5.
crunched \- Manual page for crunched v0.13.6.
.SH DESCRIPTION
Crunched: Hello World
.SS USAGE:
Expand Down
4 changes: 2 additions & 2 deletions release/man/fyi-debug.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "FYI DEBUG" "1" "May 2024" "debug v0.13.5" "User Commands"
.TH "FYI DEBUG" "1" "May 2024" "debug v0.13.6" "User Commands"
.SH NAME
debug \- Manual page for debug v0.13.5.
debug \- Manual page for debug v0.13.6.
.SH DESCRIPTION
Debug: Hello World
.SS USAGE:
Expand Down
4 changes: 2 additions & 2 deletions release/man/fyi-done.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "FYI DONE" "1" "May 2024" "done v0.13.5" "User Commands"
.TH "FYI DONE" "1" "May 2024" "done v0.13.6" "User Commands"
.SH NAME
done \- Manual page for done v0.13.5.
done \- Manual page for done v0.13.6.
.SH DESCRIPTION
Done: Hello World
.SS USAGE:
Expand Down
4 changes: 2 additions & 2 deletions release/man/fyi-error.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "FYI ERROR" "1" "May 2024" "error v0.13.5" "User Commands"
.TH "FYI ERROR" "1" "May 2024" "error v0.13.6" "User Commands"
.SH NAME
error \- Manual page for error v0.13.5.
error \- Manual page for error v0.13.6.
.SH DESCRIPTION
Error: Hello World
.SS USAGE:
Expand Down
4 changes: 2 additions & 2 deletions release/man/fyi-info.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "FYI INFO" "1" "May 2024" "info v0.13.5" "User Commands"
.TH "FYI INFO" "1" "May 2024" "info v0.13.6" "User Commands"
.SH NAME
info \- Manual page for info v0.13.5.
info \- Manual page for info v0.13.6.
.SH DESCRIPTION
Info: Hello World
.SS USAGE:
Expand Down
4 changes: 2 additions & 2 deletions release/man/fyi-notice.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "FYI NOTICE" "1" "May 2024" "notice v0.13.5" "User Commands"
.TH "FYI NOTICE" "1" "May 2024" "notice v0.13.6" "User Commands"
.SH NAME
notice \- Manual page for notice v0.13.5.
notice \- Manual page for notice v0.13.6.
.SH DESCRIPTION
Notice: Hello World
.SS USAGE:
Expand Down
4 changes: 2 additions & 2 deletions release/man/fyi-print.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "FYI PRINT" "1" "May 2024" "print v0.13.5" "User Commands"
.TH "FYI PRINT" "1" "May 2024" "print v0.13.6" "User Commands"
.SH NAME
print \- Manual page for print v0.13.5.
print \- Manual page for print v0.13.6.
.SH DESCRIPTION
Print a message without a prefix (or with a custom one).
.SS USAGE:
Expand Down
4 changes: 2 additions & 2 deletions release/man/fyi-review.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "FYI REVIEW" "1" "May 2024" "review v0.13.5" "User Commands"
.TH "FYI REVIEW" "1" "May 2024" "review v0.13.6" "User Commands"
.SH NAME
review \- Manual page for review v0.13.5.
review \- Manual page for review v0.13.6.
.SH DESCRIPTION
Review: Hello World
.SS USAGE:
Expand Down
4 changes: 2 additions & 2 deletions release/man/fyi-success.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "FYI SUCCESS" "1" "May 2024" "success v0.13.5" "User Commands"
.TH "FYI SUCCESS" "1" "May 2024" "success v0.13.6" "User Commands"
.SH NAME
success \- Manual page for success v0.13.5.
success \- Manual page for success v0.13.6.
.SH DESCRIPTION
Success: Hello World
.SS USAGE:
Expand Down
4 changes: 2 additions & 2 deletions release/man/fyi-task.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "FYI TASK" "1" "May 2024" "task v0.13.5" "User Commands"
.TH "FYI TASK" "1" "May 2024" "task v0.13.6" "User Commands"
.SH NAME
task \- Manual page for task v0.13.5.
task \- Manual page for task v0.13.6.
.SH DESCRIPTION
Task: Hello World
.SS USAGE:
Expand Down
Loading

0 comments on commit cd9ce56

Please sign in to comment.