diff options
| author | mo8it <mo8it@proton.me> | 2024-08-25 23:53:50 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-08-25 23:53:50 +0200 |
| commit | b1898f6d8b2c2ae45279ca4c67fa1b1a94acb936 (patch) | |
| tree | 25022e8fc2bc6254fc819d98ea278f04dd5d6bab /src/init.rs | |
| parent | d29e9e7e07a16adda35aea9ce9dd120b6ecc9dfc (diff) | |
Use queue instead of Stylize
Diffstat (limited to 'src/init.rs')
| -rw-r--r-- | src/init.rs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/init.rs b/src/init.rs index 2c172dc..40d9910 100644 --- a/src/init.rs +++ b/src/init.rs @@ -1,5 +1,8 @@ use anyhow::{bail, Context, Result}; -use crossterm::style::Stylize; +use crossterm::{ + style::{Attribute, Color, ResetColor, SetAttribute, SetForegroundColor}, + QueueableCommand, +}; use serde::Deserialize; use std::{ env::set_current_dir, @@ -144,12 +147,13 @@ pub fn init() -> Result<()> { .status(); } - writeln!( - stdout, - "{}\n\n{}", - "Initialization done ✓".green(), - POST_INIT_MSG.bold(), - )?; + stdout.queue(SetForegroundColor(Color::Green))?; + stdout.write_all("Initialization done ✓\n\n".as_bytes())?; + stdout + .queue(ResetColor)? + .queue(SetAttribute(Attribute::Bold))?; + stdout.write_all(POST_INIT_MSG)?; + stdout.queue(ResetColor)?; Ok(()) } @@ -182,5 +186,6 @@ You probably already initialized Rustlings. Run `cd rustlings` Then run `rustlings` again"; -const POST_INIT_MSG: &str = "Run `cd rustlings` to go into the generated directory. -Then run `rustlings` to get started."; +const POST_INIT_MSG: &[u8] = b"Run `cd rustlings` to go into the generated directory. +Then run `rustlings` to get started. +"; |
