Skip to content

Commit a95573f

Browse files
committed
release: 1.8.0
2 parents 366a4e2 + 479a963 commit a95573f

24 files changed

+340
-154
lines changed

CREDITS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Project Dependencies
22
Package: fyi
3-
Version: 1.7.1
3+
Version: 1.8.0
44
Target: x86_64-unknown-linux-gnu
5-
Generated: 2025-02-26 03:54:37 UTC
5+
Generated: 2025-03-12 03:51:06 UTC
66

77
| Package | Version | Author(s) | License |
88
| ---- | ---- | ---- | ---- |
9-
| [**argyle**](https://github.com/Blobfolio/argyle) | 0.11.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
9+
| [**argyle**](https://github.com/Blobfolio/argyle) | 0.12.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
1010
| [**dactyl**](https://github.com/Blobfolio/dactyl) | 0.10.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
11-
| [**fyi_msg**](https://github.com/Blobfolio/fyi) | 1.7.1 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
11+
| [**fyi_msg**](https://github.com/Blobfolio/fyi) | 1.8.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
1212
| [tz-rs](https://github.com/x-hgg-x/tz-rs) | 0.7.0 | x-hgg-x | MIT OR Apache-2.0 |
1313
| [**utc2k**](https://github.com/Blobfolio/utc2k) | 0.12.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
1414

fyi/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fyi"
3-
version = "1.7.1"
3+
version = "1.8.0"
44
license = "WTFPL"
55
authors = ["Josh Stoik <josh@blobfolio.com>"]
66
edition = "2024"
@@ -170,13 +170,13 @@ description = "The message!"
170170
subcommands = [ "confirm", "print", "crunched", "debug", "done", "error", "info", "notice", "review", "skipped", "success", "task", "warning" ]
171171

172172
[build-dependencies]
173-
argyle = "0.11.*"
173+
argyle = "0.12.*"
174174

175175
[build-dependencies.fyi_msg]
176176
path = "../fyi_msg"
177177

178178
[dependencies]
179-
argyle = "0.11.*"
179+
argyle = "0.12.*"
180180
dactyl = "0.10.*"
181181

182182
[dependencies.fyi_msg]

fyi/build.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
# FYI: Build
33
*/
44

5-
use argyle::KeyWordsBuilder;
5+
use argyle::{
6+
FlagsBuilder,
7+
KeyWordsBuilder,
8+
};
69
use fyi_msg::{
710
Msg,
811
MsgKind,
@@ -21,13 +24,16 @@ use std::path::{
2124
///
2225
/// It also generates the keywords used for CLI parsing, again to save some
2326
/// runtime overhead.
24-
pub fn main() {
27+
fn main() {
2528
println!("cargo:rerun-if-changed=help");
2629
println!("cargo:rerun-if-env-changed=CARGO_PKG_VERSION");
2730

2831
// Build the CLI arguments.
2932
write_cli();
3033

34+
// Build the flags.
35+
write_flags();
36+
3137
// Handle the top.
3238
write_help(
3339
help_path("top"),
@@ -173,6 +179,16 @@ fn write_cli() {
173179
builder.save(out_path("argyle-msg.rs"));
174180
}
175181

182+
/// # Write flags (program settings bools).
183+
fn write_flags() {
184+
FlagsBuilder::new("Flags")
185+
.with_flag("Indent", Some("# Indent Message."))
186+
.with_flag("Stderr", Some("# Print to STDERR."))
187+
.with_flag("Timestamp", Some("# Timestamp Message."))
188+
.with_flag("Yes", Some("# Assume Yes (No Prompt)."))
189+
.save(out_path("flags.rs"));
190+
}
191+
176192
/// # Write file.
177193
fn write_help<P>(path: P, data: &[u8])
178194
where P: AsRef<Path> {

fyi/src/cli.rs

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::FyiError;
1010
use dactyl::traits::BytesToUnsigned;
1111
use fyi_msg::{
1212
Msg,
13+
MsgFlags,
1314
MsgKind,
1415
};
1516
use std::{
@@ -19,76 +20,65 @@ use std::{
1920

2021

2122

23+
// Flags generated by build.rs.
24+
include!(concat!(env!("OUT_DIR"), "/flags.rs"));
25+
26+
27+
2228
#[derive(Debug, Clone, Copy)]
2329
/// # Message Settings.
2430
///
2531
/// Most of these settings will get embedded into the `Msg` itself, but there
2632
/// are a couple parts that do not get referenced until print time.
2733
pub(super) struct Settings {
2834
/// # Flags.
29-
flags: u8,
35+
flags: Flags,
3036

3137
/// # Exit.
3238
exit: ExitCode,
3339
}
3440

3541
impl Settings {
36-
/// # Indent Message.
37-
const FLAG_INDENT: u8 = 0b0001;
38-
39-
/// # Print to STDERR.
40-
const FLAG_STDERR: u8 = 0b0010;
41-
42-
/// # Include Timestamp.
43-
const FLAG_TIMESTAMP: u8 = 0b0100;
44-
45-
/// # Default Yes (for Prompt).
46-
const FLAG_YES: u8 = 0b1000;
47-
4842
/// # Exit Code.
4943
pub(super) fn exit(self) -> Result<(), FyiError> {
5044
if self.exit == ExitCode::SUCCESS { Ok(()) }
5145
else { Err(FyiError::Passthrough(self.exit)) }
5246
}
5347

5448
/// # Stderr?
55-
pub(super) const fn stderr(self) -> bool {
56-
Self::FLAG_STDERR == self.flags & Self::FLAG_STDERR
57-
}
49+
pub(super) const fn stderr(self) -> bool { self.flags.contains(Flags::Stderr) }
5850

5951
/// # Default Yes?
60-
pub(super) const fn yes(self) -> bool {
61-
Self::FLAG_YES == self.flags & Self::FLAG_YES
62-
}
52+
pub(super) const fn yes(self) -> bool { self.flags.contains(Flags::Yes) }
6353

6454
/// # Convert to `Msg` Flags.
65-
const fn msg_flags(self) -> u8 {
66-
let mut flags: u8 = fyi_msg::FLAG_NEWLINE;
67-
if Self::FLAG_INDENT == self.flags & Self::FLAG_INDENT {
68-
flags |= fyi_msg::FLAG_INDENT;
55+
const fn msg_flags(self) -> MsgFlags {
56+
let mut flags = MsgFlags::Newline;
57+
if self.flags.contains(Flags::Indent) {
58+
flags = flags.with(MsgFlags::Indent);
6959
}
70-
if Self::FLAG_TIMESTAMP == self.flags & Self::FLAG_TIMESTAMP {
71-
flags |= fyi_msg::FLAG_TIMESTAMP;
60+
if self.flags.contains(Flags::Timestamp) {
61+
flags = flags.with(MsgFlags::Timestamp);
7262
}
7363
flags
7464
}
7565

7666
/// # New.
7767
const fn new() -> Self {
78-
Self { flags: 0, exit: ExitCode::SUCCESS }
68+
Self { flags: Flags::None, exit: ExitCode::SUCCESS }
7969
}
8070

8171
/// # Set Indent.
82-
fn set_indent(&mut self) { self.flags |= Self::FLAG_INDENT; }
72+
fn set_indent(&mut self) { self.flags |= Flags::Indent; }
8373

8474
/// # Set Stderr.
85-
fn set_stderr(&mut self) { self.flags |= Self::FLAG_STDERR; }
75+
fn set_stderr(&mut self) { self.flags |= Flags::Stderr; }
8676

8777
/// # Set Timestamp.
88-
fn set_timestamp(&mut self) { self.flags |= Self::FLAG_TIMESTAMP; }
78+
fn set_timestamp(&mut self) { self.flags |= Flags::Timestamp; }
8979

9080
/// # Set Yes.
91-
fn set_yes(&mut self) { self.flags |= Self::FLAG_YES; }
81+
fn set_yes(&mut self) { self.flags |= Flags::Yes; }
9282
}
9383

9484

fyi_msg/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fyi_msg"
3-
version = "1.7.1"
3+
version = "1.8.0"
44
authors = ["Josh Stoik <josh@blobfolio.com>"]
55
edition = "2024"
66
rust-version = "1.85"
@@ -17,6 +17,9 @@ features = [ "fitted", "progress", "signals", "timestamps" ]
1717
default-target = "x86_64-unknown-linux-gnu"
1818
targets = [ "x86_64-unknown-linux-gnu", "x86_64-apple-darwin" ]
1919

20+
[build-dependencies]
21+
argyle = "0.12.0"
22+
2023
[dependencies]
2124
dactyl = "0.10.*"
2225

fyi_msg/build.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*!
2+
# FYI: Build
3+
*/
4+
5+
#![allow(unused_mut, reason = "It is conditionally used.")]
6+
7+
use argyle::FlagsBuilder;
8+
use std::{
9+
fs::File,
10+
io::Write,
11+
path::PathBuf,
12+
};
13+
14+
15+
16+
/// # Build `MsgFlags`.
17+
fn main() {
18+
let mut builder = FlagsBuilder::new("MsgFlags")
19+
.public()
20+
.with_docs("# Message Flags.
21+
22+
Used by [`Msg::with_flags`] to set multiple properties in one go.")
23+
.with_flag("Indent", Some("# Indent Message (four spaces).\n\nEquivalent to passing one to [`Msg::with_indent`]."))
24+
.with_flag("Newline", Some("# End Message w/ Line Break.\n\nEquivalent to passing true to [`Msg::with_newline`]."));
25+
26+
#[cfg(feature = "timestamps")]
27+
{
28+
builder = builder.with_flag("Timestamp", Some("# Timestamp Message.\n\nEquivalent to passing true to [`Msg::with_timestamp`]."));
29+
}
30+
31+
// Save it manually so we can note the timestamps feature-gate.
32+
let out = builder.to_string()
33+
.replace(
34+
"\t#[doc = \"# Timestamp",
35+
"\t#[cfg_attr(docsrs, doc(cfg(feature = \"timestamps\")))]\n\t#[doc = \"# Timestamp",
36+
);
37+
38+
File::create(out_path("msg-flags.rs"))
39+
.and_then(|mut f| f.write_all(out.as_bytes()).and_then(|()| f.flush()))
40+
.expect("Unable to save msg-flags.rs");
41+
}
42+
43+
/// # Output Path.
44+
///
45+
/// Append the sub-path to OUT_DIR and return it.
46+
fn out_path(stub: &str) -> PathBuf {
47+
std::fs::canonicalize(std::env::var("OUT_DIR").expect("Missing OUT_DIR."))
48+
.expect("Missing OUT_DIR.")
49+
.join(stub)
50+
}

fyi_msg/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ pub use msg::{
122122
};
123123

124124
pub use msg::{
125-
FLAG_INDENT,
126-
FLAG_NEWLINE,
125+
MsgFlags,
127126
kind::MsgKind,
128127
Msg,
129128
};
@@ -147,10 +146,6 @@ pub use progress::{
147146
#[cfg_attr(docsrs, doc(cfg(feature = "signal-hook")))]
148147
#[cfg(feature = "signal-hook")] pub use signal_hook;
149148

150-
#[cfg(feature = "timestamps")]
151-
#[cfg_attr(docsrs, doc(cfg(feature = "timestamps")))]
152-
pub use msg::FLAG_TIMESTAMP;
153-
154149
#[macro_use]
155150
/// # Macros.
156151
mod macros {

0 commit comments

Comments
 (0)