Skip to content

Commit acfff73

Browse files
committed
release: 2.4.0
2 parents 996a88d + f1c3f97 commit acfff73

27 files changed

+320
-278
lines changed

CREDITS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Project Dependencies
22
Package: fyi
3-
Version: 2.3.1
3+
Version: 2.4.0
44
Target: x86_64-unknown-linux-gnu
5-
Generated: 2025-08-22 04:05:19 UTC
5+
Generated: 2025-09-19 01:58:59 UTC
66

77
| Package | Version | Author(s) | License |
88
| ---- | ---- | ---- | ---- |
99
| [**argyle**](https://github.com/Blobfolio/argyle) | 0.13.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
1010
| [**dactyl**](https://github.com/Blobfolio/dactyl) | 0.13.1 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
1111
| [**fyi_ansi**](https://github.com/Blobfolio/fyi) | 2.2.1 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
12-
| [**fyi_msg**](https://github.com/Blobfolio/fyi) | 2.3.1 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
12+
| [**fyi_msg**](https://github.com/Blobfolio/fyi) | 2.4.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
1313
| [tz-rs](https://github.com/x-hgg-x/tz-rs) | 0.7.0 | x-hgg-x | MIT OR Apache-2.0 |
14-
| [**utc2k**](https://github.com/Blobfolio/utc2k) | 0.17.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
14+
| [**utc2k**](https://github.com/Blobfolio/utc2k) | 0.17.1 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
1515

1616
### Legend
1717

fyi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fyi"
3-
version = "2.3.1"
3+
version = "2.4.0"
44
license = "WTFPL"
55
authors = ["Josh Stoik <josh@blobfolio.com>"]
66
edition = "2024"

fyi_msg/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fyi_msg"
3-
version = "2.3.1"
3+
version = "2.4.0"
44
authors = ["Josh Stoik <josh@blobfolio.com>"]
55
edition = "2024"
66
rust-version = "1.88"

fyi_msg/benches/fm_msg.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ benches!(
2121
Bench::new("fyi_msg::Msg::from()")
2222
.run(|| Msg::from(TEXT)),
2323

24+
Bench::spacer(),
25+
2426
Bench::new("fyi_msg::Msg::error()")
2527
.run(|| Msg::error(TEXT)),
2628

@@ -33,6 +35,8 @@ benches!(
3335
Bench::new("fyi_msg::Msg::new((Prefix, 199))")
3436
.run(|| Msg::new(("Prefix", AnsiColor::Misc199), TEXT)),
3537

38+
Bench::spacer(),
39+
3640
Bench::new("fyi_msg::MsgKind::into_msg()")
3741
.run(|| MsgKind::Error.into_msg(TEXT)),
3842
);

fyi_msg/examples/msg.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ fn main() {
7979

8080
println!();
8181

82-
// A prompt to STDERR.
83-
if Msg::new(MsgKind::Confirm, "Did this print to STDERR?").eprompt_with_default(true) {
82+
// A prompt to STDERR using the macro, defaulting to yes.
83+
if confirm!(@stderr @yes "Was this message printed to STDERR?") {
8484
Msg::from("Great!")
8585
.with_newline(true)
8686
.print();
@@ -91,8 +91,8 @@ fn main() {
9191
.print();
9292
}
9393

94-
// Here's that macro we mentioned earlier.
95-
if confirm!(yes: "Was this example useful?") {
94+
// A prompt that defaults to yes, but prints to STDOUT instead.
95+
if confirm!(@yes "Was this example useful?") {
9696
Msg::from("Great!")
9797
.with_newline(true)
9898
.print();
@@ -103,8 +103,8 @@ fn main() {
103103
.print();
104104
}
105105

106-
// Test confirmation with indentation.
107-
if confirm!(yes: "Is this confirmation indented?", 1) {
106+
// An indented prompt defaulting to yes.
107+
if confirm!(@indent 1 @yes "Is this confirmation indented?") {
108108
Msg::from("Great!")
109109
.with_indent(1)
110110
.with_newline(true)
@@ -117,7 +117,8 @@ fn main() {
117117
.print();
118118
}
119119

120-
if confirm!("Do you hate fun?", 2) {
120+
// A differently-indented prompt, default to no.
121+
if confirm!(@indent 2 "Do you hate fun?") {
121122
Msg::from("That's weird.")
122123
.with_indent(2)
123124
.with_newline(true)

fyi_msg/examples/progless-sigint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn main() {
5050
pbar.finish();
5151

5252
// Go again?
53-
if fyi_msg::confirm!(yes: "Count some more?") {
53+
if fyi_msg::confirm!(@yes "Count some more?") {
5454
pbar.reset(NonZeroU32::new(250).unwrap());
5555
pbar.set_title(Some(Msg::task("More numbers…")));
5656
for _ in 500..750 {

fyi_msg/src/lib.rs

Lines changed: 101 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ mod macros {
144144
#[macro_export(local_inner_macros)]
145145
/// # Confirm.
146146
///
147-
/// This is a convenience macro for generating a confirmation message,
148-
/// handling the prompting, and returning the response `bool`.
147+
/// This convenience macro prints a message, prompts the user for a
148+
/// yes/no response, and interprets/returns that value as a `bool`.
149149
///
150150
/// ## Example
151151
///
@@ -161,47 +161,125 @@ mod macros {
161161
/// if confirm!("Do you like chickens?") {
162162
/// println!("That's great! They like you too!");
163163
/// }
164+
/// ```
165+
///
166+
/// The following modifiers are supported:
167+
/// * `@indent $literal`: indent the message `$literal` "tabs";
168+
/// * `@stderr`: pop the question over STDERR (instead of STDOUT);
169+
/// * `@yes`: default to "Y" (instead of "N");
170+
///
171+
/// ```no_run
172+
/// # use fyi_msg::confirm;
173+
/// // Indent one "tabs" (four spaces):
174+
/// if confirm!(@indent 1 "Do you like chickens?") {
175+
/// println!(" That's great! They like you too!");
176+
/// }
164177
///
165-
/// // If you want to default to yes, prefix thusly:
166-
/// if confirm!(yes: "Do you like chickens?") {
178+
/// // Print to STDERR instead of STDOUT:
179+
/// if confirm!(@stderr "Do you like chickens?") {
167180
/// println!("That's great! They like you too!");
168181
/// }
169182
///
170-
/// // Indentation can be set with the macro too by appending a second
171-
/// // argument:
172-
/// if confirm!("Do you like chickens?", 1) {
173-
/// println!(" That's great! They like you too!");
183+
/// // Default to yes instead of no.
184+
/// if confirm!(@yes "Do you like chickens?") {
185+
/// println!("That's great! They like you too!");
174186
/// }
187+
/// ```
175188
///
176-
/// // The "yes:" prefix also works here.
177-
/// if confirm!(yes: "Do you like chickens?", 1) {
178-
/// println!(" That's great! They like you too!");
189+
/// Modifiers can be stacked together any which way.
190+
///
191+
/// ```no_run
192+
/// # use fyi_msg::confirm;
193+
/// // Indent three "tabs" _and_ print to STDERR _and_ default to yes:
194+
/// if confirm!(@indent 3 @stderr @yes "Do you like chickens?") {
195+
/// println!(" That's great! They like you too!");
179196
/// }
197+
///
198+
/// // Same as above.
199+
/// if confirm!(@stderr @indent 3 @yes "Do you like chickens?") {
200+
/// println!(" That's great! They like you too!");
201+
/// }
202+
///
203+
/// // Same again.
204+
/// if confirm!(@stderr @yes @indent 3 "Do you like chickens?") {
205+
/// println!(" That's great! They like you too!");
206+
/// }
207+
///
208+
/// // …
180209
/// ```
181210
macro_rules! confirm {
182-
(yes: $text:expr) => (
183-
$crate::Msg::new($crate::MsgKind::Confirm, $text).prompt_with_default(true)
211+
// Maybe-indent.
212+
($( @indent $indent:literal )? $text:expr) => (
213+
$crate::Msg::new($crate::MsgKind::Confirm, $text)
214+
$( .with_indent($indent) )?
215+
.prompt()
184216
);
185-
(yes: $text:expr, $indent:expr) => (
217+
218+
// Maybe-indent, yes.
219+
($( @indent $indent:literal )? @yes $text:expr) => (
186220
$crate::Msg::new($crate::MsgKind::Confirm, $text)
187-
.with_indent($indent)
221+
$( .with_indent($indent) )?
188222
.prompt_with_default(true)
189223
);
190-
(no: $text:expr) => (
191-
$crate::Msg::new($crate::MsgKind::Confirm, $text).prompt()
224+
// Maybe-indent, yes.
225+
(@yes $( @indent $indent:literal )? $text:expr) => (
226+
$crate::Msg::new($crate::MsgKind::Confirm, $text)
227+
$( .with_indent($indent) )?
228+
.prompt_with_default(true)
192229
);
193-
(no: $text:expr, $indent:expr) => (
230+
231+
// Maybe-indent, STDERR.
232+
($( @indent $indent:literal )? @stderr $text:expr) => (
233+
$crate::Msg::new($crate::MsgKind::Confirm, $text)
234+
$( .with_indent($indent) )?
235+
.eprompt()
236+
);
237+
(@stderr $( @indent $indent:literal )? $text:expr) => (
238+
$crate::Msg::new($crate::MsgKind::Confirm, $text)
239+
$( .with_indent($indent) )?
240+
.eprompt()
241+
);
242+
243+
// STDERR, yes.
244+
(@stderr @yes $text:expr) => (
245+
$crate::Msg::new($crate::MsgKind::Confirm, $text)
246+
.eprompt_with_default(true)
247+
);
248+
(@yes @stderr $text:expr) => (
249+
$crate::Msg::new($crate::MsgKind::Confirm, $text)
250+
.eprompt_with_default(true)
251+
);
252+
253+
// Indent, STDERR, yes.
254+
(@indent $indent:literal @stderr @yes $text:expr) => (
194255
$crate::Msg::new($crate::MsgKind::Confirm, $text)
195256
.with_indent($indent)
196-
.prompt()
257+
.eprompt_with_default(true)
197258
);
198-
($text:expr) => (
199-
$crate::Msg::new($crate::MsgKind::Confirm, $text).prompt()
259+
(@indent $indent:literal @yes @stderr $text:expr) => (
260+
$crate::Msg::new($crate::MsgKind::Confirm, $text)
261+
.with_indent($indent)
262+
.eprompt_with_default(true)
200263
);
201-
($text:expr, $indent:expr) => (
264+
(@stderr @indent $indent:literal @yes $text:expr) => (
202265
$crate::Msg::new($crate::MsgKind::Confirm, $text)
203266
.with_indent($indent)
204-
.prompt()
267+
.eprompt_with_default(true)
268+
);
269+
(@stderr @yes @indent $indent:literal $text:expr) => (
270+
$crate::Msg::new($crate::MsgKind::Confirm, $text)
271+
.with_indent($indent)
272+
.eprompt_with_default(true)
273+
);
274+
(@yes @indent $indent:literal @stderr $text:expr) => (
275+
$crate::Msg::new($crate::MsgKind::Confirm, $text)
276+
.with_indent($indent)
277+
.eprompt_with_default(true)
278+
);
279+
(@yes @stderr @indent $indent:literal $text:expr) => (
280+
$crate::Msg::new($crate::MsgKind::Confirm, $text)
281+
.with_indent($indent)
282+
.eprompt_with_default(true)
205283
);
206284
}
207285
}

0 commit comments

Comments
 (0)