fix: prompt via readline
This commit is contained in:
parent
77ba311bab
commit
17b3334aea
2 changed files with 2 additions and 11 deletions
|
@ -10,15 +10,6 @@ pub fn some_non_empty(str: &str) -> Option<String> {
|
|||
if str.is_empty() { None } else { Some(str.to_string()) }
|
||||
}
|
||||
|
||||
pub fn prompt(prompt: &str) -> Option<String> {
|
||||
print!("{} ", prompt);
|
||||
stdout().flush().unwrap();
|
||||
match stdin().lines().next() {
|
||||
Some(Ok(line)) => Some(line),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Parses the hour from a plain number in the String,
|
||||
/// with max of max_future hours into the future.
|
||||
pub fn parse_hour(str: &str, max_future: i64) -> Option<DateTime<Local>> {
|
||||
|
|
|
@ -168,7 +168,7 @@ async fn main() {
|
|||
Ok(Ok(key)) => key,
|
||||
_ => {
|
||||
warn!("Could not read keys from {}", keysfile.to_string_lossy());
|
||||
let keys = prompt("Secret key?")
|
||||
let keys = or_warn!(rl.readline("Secret key? "))
|
||||
.and_then(|s| or_warn!(Keys::from_str(&s)))
|
||||
.unwrap_or_else(|| {
|
||||
info!("Generating and persisting new key");
|
||||
|
@ -195,7 +195,7 @@ async fn main() {
|
|||
}
|
||||
Err(e) => {
|
||||
warn!("Could not read relays file: {}", e);
|
||||
if let Some(line) = prompt("Relay?") {
|
||||
if let Ok(line) = rl.readline("Relay? ") {
|
||||
let url = if line.contains("://") {
|
||||
line
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue