Skip to content

Commit

Permalink
use prompt highlighter to highlight prompt correctly for both mac and…
Browse files Browse the repository at this point in the history
… windows. (MystenLabs#3133)
  • Loading branch information
patrickkuo authored Jul 12, 2022
1 parent 2cf2892 commit d27227f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions crates/sui/src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use anyhow::anyhow;
use std::borrow::Cow;
use std::borrow::Cow::Owned;
use std::cmp::Ordering;
use std::collections::BTreeMap;
use std::env;
Expand Down Expand Up @@ -73,9 +75,6 @@ impl<P: Display, S: Send, H: AsyncHandler<S>> Shell<P, S, H> {
}));

loop {
write!(out, "{}", format!("{}", self.prompt).bold().green())?;
out.flush()?;

// Read a line
let readline = rl.readline(&self.prompt.to_string());
let line = match readline {
Expand Down Expand Up @@ -196,7 +195,15 @@ impl Hinter for ShellHelper {
type Hint = String;
}

impl Highlighter for ShellHelper {}
impl Highlighter for ShellHelper {
fn highlight_prompt<'b, 's: 'b, 'p: 'b>(
&'s self,
prompt: &'p str,
_default: bool,
) -> Cow<'b, str> {
Owned(prompt.bold().green().to_string())
}
}

impl Validator for ShellHelper {}

Expand Down

0 comments on commit d27227f

Please sign in to comment.