diff --git a/src/main.rs b/src/main.rs index ce2ebde..935329e 100644 --- a/src/main.rs +++ b/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) => { diff --git a/src/prompt.rs b/src/prompt.rs new file mode 100644 index 0000000..c5fabb9 --- /dev/null +++ b/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!("» ") + } +}