Skip to content

Commit

Permalink
feat(lib): wait for user
Browse files Browse the repository at this point in the history
  • Loading branch information
apogeeoak committed Jan 8, 2024
1 parent 7570c13 commit c25714f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# IDE settings.
/.vscode

# Local files.
/local

# Rust output.
/target
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,6 +18,8 @@ pub fn main() -> Result<(), Box<dyn Error>> {
print_labels(&config);
print_items(&config);

wait_for_user();

Ok(())
}

Expand Down Expand Up @@ -46,3 +49,9 @@ fn print_items(config: &Config) {
println!("{}", library::format::row(items));
}
}

fn wait_for_user() {
print!("\nPress <enter> to exit: ");
stdout().flush().expect("Error writing output.");
stdin().read_line(&mut String::new()).expect("Error reading input.");
}

0 comments on commit c25714f

Please # to comment.