Skip to content

Commit

Permalink
fix(cli): correctly print user prompt for termination
Browse files Browse the repository at this point in the history
  • Loading branch information
w568w committed Jun 23, 2024
1 parent 365c3f6 commit d7c6302
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use either::Either;
use indicatif::ProgressBar;
use serde::{Deserialize, Serialize};
use std::{
fs::read_to_string,
sync::atomic::{AtomicBool, Ordering},
fs::read_to_string, io::Write, sync::atomic::{AtomicBool, Ordering}
};

/// A command line tool for importing JSON files into curriculum database.
Expand Down Expand Up @@ -175,6 +174,7 @@ async fn main() -> Result<()> {
if TERMINATE.load(Ordering::SeqCst) {
let mut input = String::new();
print!("Do you want to stop the program? (y/N) ");
let _ = std::io::stdout().flush();
std::io::stdin()
.read_line(&mut input)
.expect("Failed to read input");
Expand Down Expand Up @@ -207,16 +207,17 @@ async fn main() -> Result<()> {
.json(&new_course)
.send()
.await?;


pb.inc(1);

if !resq.status().is_success() {
println!(
"Failed to import course `{:?}`: {}",
new_course,
resq.text().await?
);
continue;
}
pb.inc(1);

}
pb.finish();
println!("Congratulations! All courses have been imported successfully!");
Expand Down

0 comments on commit d7c6302

Please sign in to comment.