From c25714f413edbbb1a92221d3a178a7203df105fc Mon Sep 17 00:00:00 2001 From: apogeeoak <59737221+apogeeoak@users.noreply.github.com> Date: Mon, 8 Jan 2024 15:01:13 -0500 Subject: [PATCH] feat(lib): wait for user --- .gitignore | 3 +++ src/lib.rs | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index b76ebf1..f8c5681 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ # IDE settings. /.vscode +# Local files. +/local + # Rust output. /target diff --git a/src/lib.rs b/src/lib.rs index df9add5..b733ca8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ use crate::{config::Config, library::format::Row}; use rand::prelude::*; use std::error::Error; +use std::io::{stdin, stdout, Write}; mod config; mod library; @@ -17,6 +18,8 @@ pub fn main() -> Result<(), Box> { print_labels(&config); print_items(&config); + wait_for_user(); + Ok(()) } @@ -46,3 +49,9 @@ fn print_items(config: &Config) { println!("{}", library::format::row(items)); } } + +fn wait_for_user() { + print!("\nPress to exit: "); + stdout().flush().expect("Error writing output."); + stdin().read_line(&mut String::new()).expect("Error reading input."); +}