Use console's read_key instead of read_char (#629)

read_char returns an error if keys such as CapsLock are pressed
This commit is contained in:
Roey Darwish Dror
2021-02-13 06:26:50 +02:00
committed by GitHub
parent 16ff9faec6
commit 0fe0c70b2b
3 changed files with 238 additions and 187 deletions

View File

@@ -22,6 +22,7 @@ use self::error::Upgraded;
use self::steps::{remote::*, *};
use self::terminal::*;
use anyhow::{anyhow, Result};
use console::Key;
use log::debug;
use std::env;
@@ -390,14 +391,14 @@ fn run() -> Result<()> {
if config.keep_at_end() {
print_info("\n(R)eboot\n(S)hell\n(Q)uit");
loop {
match get_char() {
's' | 'S' => {
match get_key() {
Ok(Key::Char('s')) | Ok(Key::Char('S')) => {
run_shell();
}
'r' | 'R' => {
Ok(Key::Char('r')) | Ok(Key::Char('R')) => {
reboot();
}
'q' | 'Q' => (),
Ok(Key::Char('q')) | Ok(Key::Char('Q')) => (),
_ => {
continue;
}