Galaxy-brained newline intersperse function
Itertools already has an intersperse method for me. Why would I build my own when I can do this? There's even a `fold()` over the units that come out of the print routine.
This commit is contained in:
@@ -6,6 +6,7 @@ edition = "2024"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.0.7", features = ["derive", "env"] }
|
clap = { version = "4.0.7", features = ["derive", "env"] }
|
||||||
colored = "2.0.0"
|
colored = "2.0.0"
|
||||||
|
itertools = "0.10.0"
|
||||||
reqwest = { version = "0.11.13", features = ["json", "stream", "multipart"] }
|
reqwest = { version = "0.11.13", features = ["json", "stream", "multipart"] }
|
||||||
serde = { version = "1.0.152", features = ["derive"] }
|
serde = { version = "1.0.152", features = ["derive"] }
|
||||||
tokio = { version = "1.24.2", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.24.2", features = ["macros", "rt-multi-thread"] }
|
||||||
|
|||||||
11
src/main.rs
11
src/main.rs
@@ -6,6 +6,7 @@ use gt_tool::structs::release::{CreateReleaseOption, Release};
|
|||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
|
use itertools::Itertools;
|
||||||
use reqwest::header;
|
use reqwest::header;
|
||||||
use reqwest::header::ACCEPT;
|
use reqwest::header::ACCEPT;
|
||||||
|
|
||||||
@@ -36,9 +37,13 @@ async fn main() -> Result<(), gt_tool::Error> {
|
|||||||
// Print in reverse order so the newest items are closest to the
|
// Print in reverse order so the newest items are closest to the
|
||||||
// user's command prompt. Otherwise the newest item scrolls off the
|
// user's command prompt. Otherwise the newest item scrolls off the
|
||||||
// screen and can't be seen.
|
// screen and can't be seen.
|
||||||
for release in releases.iter().rev() {
|
let _ = releases
|
||||||
println!("{}", release);
|
.iter()
|
||||||
}
|
.rev()
|
||||||
|
.map(|release| release.to_string())
|
||||||
|
.intersperse(String::from(""))
|
||||||
|
.map(|release| println!("{}", release))
|
||||||
|
.fold((), |_, _| () );
|
||||||
}
|
}
|
||||||
gt_tool::cli::Commands::CreateRelease {
|
gt_tool::cli::Commands::CreateRelease {
|
||||||
name,
|
name,
|
||||||
|
|||||||
Reference in New Issue
Block a user