Browse Source

refactoring: remove prompt format path argument

main
fdai7451 2 years ago
parent
commit
04c41aaa93
  1. 18
      src/prompt.rs

18
src/prompt.rs

@ -1,4 +1,4 @@
use std::path::PathBuf;
use std::env;
#[derive(Clone)]
pub enum PromptStyle {
@ -7,18 +7,20 @@ pub enum PromptStyle {
}
impl PromptStyle {
pub fn fmt_style(&self, path: PathBuf) -> String {
pub fn fmt_style(&self) -> String {
match self {
PromptStyle::None => self.fmt_none(path),
PromptStyle::SimpleDirectory => self.fmt_simple_directory(path),
PromptStyle::None => self.fmt_none(),
PromptStyle::SimpleDirectory => self.fmt_simple_directory(),
}
}
fn fmt_none(&self, _: PathBuf) -> String {
fn fmt_none(&self) -> String {
return "» ".to_string();
}
fn fmt_simple_directory(&self, path: PathBuf) -> String {
fn fmt_simple_directory(&self) -> String {
let path = env::current_dir().unwrap_or_default();
return format!("{} » ", path.to_string_lossy());
}
}
@ -35,8 +37,6 @@ impl Prompt {
}
pub fn get_prompt(&mut self) -> String {
let path = std::env::current_dir().unwrap();
return self.style.fmt_style(path);
return self.style.fmt_style();
}
}
Loading…
Cancel
Save