From 44941a79d8a35182d30568bbcc2ca4c5f0a009e7 Mon Sep 17 00:00:00 2001 From: fdai7374 Date: Wed, 1 Feb 2023 19:41:16 +0100 Subject: [PATCH] feat: print command bold --- src/builtins/help.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/builtins/help.rs b/src/builtins/help.rs index 21033f8..d75df35 100644 --- a/src/builtins/help.rs +++ b/src/builtins/help.rs @@ -1,3 +1,4 @@ +use colored::Colorize; use crate::builtins::{Builtin, BuiltinConfig}; use crate::error::ShellError; @@ -19,8 +20,17 @@ impl Builtin for Help { "; for line in commands.lines() { - println!("{}", line.trim_start()); + println!("{}{}", split_command(line)[0].bold(),split_command(line)[1]); } Ok(()) } } + +fn split_command(commands: &str) -> Vec<&str> { + let mut splitted_command: Vec<&str> = vec![]; + if !commands.is_empty() && commands.trim().len() >=1 { + splitted_command = commands.trim_start().splitn(2, " ").collect(); + return splitted_command + } + return vec!["",""]; +} \ No newline at end of file