Browse Source

feat: change prompt style 'None' to 'Default'

main
fdai7381 2 years ago
committed by fdai7451
parent
commit
0926afe80a
  1. 6
      src/builtins/change_prompt.rs
  2. 2
      src/builtins/mod.rs
  3. 8
      src/prompt.rs

6
src/builtins/change_prompt.rs

@ -12,7 +12,7 @@ impl Builtin for ChangePrompt {
)) ))
} else if let Some(style) = args.get(0) { } else if let Some(style) = args.get(0) {
match style.to_lowercase().as_str() { match style.to_lowercase().as_str() {
"none" => config.prompt_style = PromptStyle::None,
"default" => config.prompt_style = PromptStyle::Default,
"simple-directory" | "simple_directory" | "simpledirectory" => { "simple-directory" | "simple_directory" | "simpledirectory" => {
config.prompt_style = PromptStyle::SimpleDirectory config.prompt_style = PromptStyle::SimpleDirectory
} }
@ -61,9 +61,9 @@ mod tests {
} }
#[test] #[test]
fn test_change_prompt_none() {
fn test_change_prompt_default() {
assert_eq!( assert_eq!(
ChangePrompt.execute(&mut BuiltinConfig::new(), vec!["none".to_string()]),
ChangePrompt.execute(&mut BuiltinConfig::new(), vec!["default".to_string()]),
Ok(()) Ok(())
) )
} }

2
src/builtins/mod.rs

@ -13,7 +13,7 @@ pub struct BuiltinConfig {
impl BuiltinConfig { impl BuiltinConfig {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
prompt_style: PromptStyle::None,
prompt_style: PromptStyle::Default,
} }
} }
} }

8
src/prompt.rs

@ -2,7 +2,7 @@ use std::env;
#[derive(Clone)] #[derive(Clone)]
pub enum PromptStyle { pub enum PromptStyle {
None,
Default,
SimpleDirectory, SimpleDirectory,
BashLike, BashLike,
} }
@ -10,13 +10,13 @@ pub enum PromptStyle {
impl PromptStyle { impl PromptStyle {
pub fn fmt_style(&self) -> String { pub fn fmt_style(&self) -> String {
match self { match self {
PromptStyle::None => self.fmt_none(),
PromptStyle::Default => self.fmt_default(),
PromptStyle::SimpleDirectory => self.fmt_simple_directory(), PromptStyle::SimpleDirectory => self.fmt_simple_directory(),
PromptStyle::BashLike => self.fmt_bash_like(), PromptStyle::BashLike => self.fmt_bash_like(),
} }
} }
fn fmt_none(&self) -> String {
fn fmt_default(&self) -> String {
"» ".to_string() "» ".to_string()
} }
@ -54,7 +54,7 @@ pub struct Prompt {
impl Prompt { impl Prompt {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
style: PromptStyle::None,
style: PromptStyle::Default,
} }
} }

Loading…
Cancel
Save