Skip to content

Commit

Permalink
fix(deps): upgrade rprompt to 2.1.1
Browse files Browse the repository at this point in the history
Migration was applied, adapting `fastmod`
to `rprompt` API changes:

<https://github.com/conradkleinespel/rprompt/releases/tag/v2.0.2>
  • Loading branch information
LeoniePhiline committed Mar 20, 2024
1 parent 5e8a473 commit 09dea5f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
18 changes: 16 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ grep = "0.2.5"
ignore = "0.4.1"
num_cpus = "1.8.0"
regex = "1.5.5"
rprompt = "1.0.3"
rprompt = "2.1.1"

[dev-dependencies]
assert_cmd = "2"
Expand Down
24 changes: 16 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ use regex::RegexBuilder;

mod terminal;

use rprompt::prompt_reply_stderr;
use rprompt::prompt_reply_stdout;
use rprompt::prompt_reply_from_bufread;

use crate::terminal::Color;

Expand Down Expand Up @@ -126,7 +125,12 @@ fn looks_like_code(path: &Path) -> bool {

fn prompt(prompt_text: &str, letters: &str, default: Option<char>) -> Result<char> {
loop {
let input = prompt_reply_stdout(prompt_text).context("Unable to read user input")?;
let input = prompt_reply_from_bufread(
&mut std::io::stdin().lock(),
&mut std::io::stdout(),
prompt_text,
)
.context("Unable to read user input")?;
if input.is_empty() && default.is_some() {
return Ok(default.unwrap());
}
Expand Down Expand Up @@ -886,11 +890,15 @@ compatibility with the original codemod.",
.build()
.with_context(|| format!("Unable to make regex from {}", regex_str))?;
if regex.is_match("") {
let _ = prompt_reply_stderr(&format!(
"Warning: your regex {:?} matches the empty string. This is probably
not what you want. Press Enter to continue anyway or Ctrl-C to quit.",
regex,
))?;
let _ = prompt_reply_from_bufread(
&mut std::io::stdin().lock(),
&mut std::io::stderr(),
&format!(
"Warning: your regex {:?} matches the empty string. This is probably
not what you want. Press Enter to continue anyway or Ctrl-C to quit.",
regex,
),
)?;
}
let matcher = RegexMatcherBuilder::new()
.case_insensitive(ignore_case)
Expand Down

0 comments on commit 09dea5f

Please sign in to comment.