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) {
match style.to_lowercase().as_str() {
"none" => config.prompt_style = PromptStyle::None,
"default" => config.prompt_style = PromptStyle::Default,
"simple-directory" | "simple_directory" | "simpledirectory" => {
config.prompt_style = PromptStyle::SimpleDirectory
}
@ -61,9 +61,9 @@ mod tests {
}
#[test]
fn test_change_prompt_none() {
fn test_change_prompt_default() {
assert_eq!(
ChangePrompt.execute(&mut BuiltinConfig::new(), vec!["none".to_string()]),
ChangePrompt.execute(&mut BuiltinConfig::new(), vec!["default".to_string()]),
Ok(())
)
}

2
src/builtins/mod.rs

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

8
src/prompt.rs

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

Loading…
Cancel
Save