Browse Source

feat: add simple prompt

main
fdai7381 2 years ago
parent
commit
8bb48f89b2
  1. 8
      src/main.rs
  2. 11
      src/prompt.rs

8
src/main.rs

@ -1,11 +1,17 @@
mod prompt;
use rustyline::error::ReadlineError;
use rustyline::{Editor, Result};
use crate::prompt::Prompt;
fn main() -> Result<()> {
let mut rl = Editor::<()>::new()?;
let mut prompt = Prompt::new();
loop {
let readline = rl.readline("» ");
let readline = rl.readline(&prompt.get_prompt());
match readline {
Ok(line) => {

11
src/prompt.rs

@ -0,0 +1,11 @@
pub struct Prompt {}
impl Prompt {
pub fn new() -> Self {
Self {}
}
pub fn get_prompt(&mut self) -> String {
format!("» ")
}
}
Loading…
Cancel
Save