From f2f50e20f85c713a466d10250621058529cc0fa0 Mon Sep 17 00:00:00 2001 From: fdai7451 Date: Sat, 21 Jan 2023 16:18:43 +0100 Subject: [PATCH] feat: add command prompt styles --- src/prompt.rs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/prompt.rs b/src/prompt.rs index 287cfb5..e3216bf 100644 --- a/src/prompt.rs +++ b/src/prompt.rs @@ -1,11 +1,35 @@ -pub struct Prompt; +use std::path::PathBuf; + +pub enum PromptStyle { + None, +} + +impl PromptStyle { + pub fn fmt_style(&self, path: PathBuf) -> String { + match self { + PromptStyle::None => self.fmt_none(path), + } + } + + fn fmt_none(&self, _: PathBuf) -> String { + return "» ".to_string(); + } +} + +pub struct Prompt { + pub style: PromptStyle, +} impl Prompt { pub fn new() -> Self { - Self {} + Self { + style: PromptStyle::None, + } } pub fn get_prompt(&mut self) -> String { - format!("» ") + let path = std::env::current_dir().unwrap(); + + return self.style.fmt_style(path); } }