Skip to content

Commit

Permalink
refactor(client): add remote.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
llenotre committed Nov 10, 2024
1 parent d279dc8 commit 8b11918
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 217 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ edition = "2021"
[dependencies]
common = { path = "../common" }
tokio = { version = "1.41.1", features = ["macros", "rt", "rt-multi-thread"] }
utils = { git = "https://github.com/maestro-os/maestro-utils" }

[features]
default = []
Expand Down
42 changes: 12 additions & 30 deletions client/src/confirm.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,20 @@
//! This module implements a confirmation prompt.
//! Confirmation prompt.
use std::{
io,
io::{BufRead, Write},
};
use common::maestro_utils;

/// Asks for confirmation. If yes, true is returned. Else, false is returned.
pub fn prompt() -> bool {
let mut first = true;
let stdin = io::stdin();
let mut response;

loop {
if first {
print!("Confirm? [y/n] ");
} else {
print!("Please type `y` or `n`. ");
}

let _ = io::stdout().flush();

// Waiting for an input line
let input = stdin.lock().lines().next().unwrap().unwrap();
response = input == "y";

// If the input is correct, stop asking
if input == "y" || input == "n" {
break;
let Some(input) = maestro_utils::prompt::prompt(Some("Confirm? [Y/n] "), false) else {
// Input closed, abort
break false;
};
let input = input.trim().to_lowercase();
match input.as_str() {
"" | "y" | "ye" | "yes" => break true,
"n" | "no" => break false,
// Retry
_ => {}
}

first = false;
}

println!();

response
}
5 changes: 4 additions & 1 deletion client/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ pub async fn install(
}
}

println!("Total download size: {}", utils::util::ByteSize(total_size));
println!(
"Total download size: {}",
common::maestro_utils::util::ByteSize(total_size)
);
}
#[cfg(not(feature = "network"))]
{
Expand Down
Loading

0 comments on commit 8b11918

Please sign in to comment.