|
@ -1,6 +1,6 @@ |
|
|
use colored::Colorize;
|
|
|
|
|
|
use crate::builtins::{Builtin, BuiltinConfig};
|
|
|
use crate::builtins::{Builtin, BuiltinConfig};
|
|
|
use crate::error::ShellError;
|
|
|
use crate::error::ShellError;
|
|
|
|
|
|
use colored::Colorize;
|
|
|
|
|
|
|
|
|
pub struct Help;
|
|
|
pub struct Help;
|
|
|
|
|
|
|
|
@ -21,18 +21,22 @@ impl Builtin for Help { |
|
|
";
|
|
|
";
|
|
|
|
|
|
|
|
|
for line in commands.lines() {
|
|
|
for line in commands.lines() {
|
|
|
println!("{}{}", split_command(line)[0].bold(), split_command(line)[1]);
|
|
|
|
|
|
|
|
|
println!(
|
|
|
|
|
|
"{}{}",
|
|
|
|
|
|
split_command(line)[0].bold(),
|
|
|
|
|
|
split_command(line)[1]
|
|
|
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
Ok(())
|
|
|
Ok(())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn split_command(commands: &str) -> Vec<&str> {
|
|
|
fn split_command(commands: &str) -> Vec<&str> {
|
|
|
if commands.trim_start().len() >= 1 {
|
|
|
|
|
|
let splitted_command = commands.trim_start().splitn(2, " ").collect();
|
|
|
|
|
|
|
|
|
if !commands.trim_start().is_empty() {
|
|
|
|
|
|
let splitted_command = commands.trim_start().splitn(2, ' ').collect();
|
|
|
return splitted_command;
|
|
|
return splitted_command;
|
|
|
}
|
|
|
}
|
|
|
return vec!["", ""];
|
|
|
|
|
|
|
|
|
vec!["", ""]
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
#[cfg(test)]
|
|
@ -42,13 +46,22 @@ mod tests { |
|
|
#[test]
|
|
|
#[test]
|
|
|
fn test_split_command_split() {
|
|
|
fn test_split_command_split() {
|
|
|
let test_string1 = "Hallo, Marcel Davis 1&1.";
|
|
|
let test_string1 = "Hallo, Marcel Davis 1&1.";
|
|
|
assert_eq!(split_command(test_string1), vec!["Hallo,", "Marcel Davis 1&1."]);
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
|
split_command(test_string1),
|
|
|
|
|
|
vec!["Hallo,", "Marcel Davis 1&1."]
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
let test_string2 = "Leiter1 23für Kundenzufriedenheit.";
|
|
|
let test_string2 = "Leiter1 23für Kundenzufriedenheit.";
|
|
|
assert_eq!(split_command(test_string2), vec!["Leiter1", "23für Kundenzufriedenheit."]);
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
|
split_command(test_string2),
|
|
|
|
|
|
vec!["Leiter1", "23für Kundenzufriedenheit."]
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
let test_string3 = "Wir# $%gehen erst wieder, wenn ihre Leitung läuft!";
|
|
|
let test_string3 = "Wir# $%gehen erst wieder, wenn ihre Leitung läuft!";
|
|
|
assert_eq!(split_command(test_string3), vec!["Wir#", "$%gehen erst wieder, wenn ihre Leitung läuft!"]);
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
|
split_command(test_string3),
|
|
|
|
|
|
vec!["Wir#", "$%gehen erst wieder, wenn ihre Leitung läuft!"]
|
|
|
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
#[test]
|
|
|