Skip to content

Commit

Permalink
Fallback to empty terminfo (#869)
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-h authored Apr 5, 2024
1 parent d6a36b8 commit 5ecf3c4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/cli/interaction.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::collections::HashMap;
use std::io::{stdin, stdout, BufRead, Write};

use eyre::{eyre, WrapErr};
Expand All @@ -20,8 +21,16 @@ pub(crate) async fn prompt(
currently_explaining: bool,
) -> eyre::Result<PromptChoice> {
let stdout = stdout();
let mut term =
term::terminfo::TerminfoTerminal::new(stdout).ok_or(eyre!("Couldn't get terminal"))?;
let terminfo = term::terminfo::TermInfo::from_env().unwrap_or_else(|_| {
tracing::warn!("Couldn't find terminfo, using empty fallback terminfo");
term::terminfo::TermInfo {
names: vec![],
bools: HashMap::new(),
numbers: HashMap::new(),
strings: HashMap::new(),
}
});
let mut term = term::terminfo::TerminfoTerminal::new_with_terminfo(stdout, terminfo);
let with_confirm = format!(
"\
{question}\n\
Expand Down

0 comments on commit 5ecf3c4

Please sign in to comment.