diff --git a/dev/lolcat.sh b/dev/lolcat.sh new file mode 100755 index 0000000..c12be90 --- /dev/null +++ b/dev/lolcat.sh @@ -0,0 +1 @@ +COLORTERM= lolcat -p 1 -F 0.3 -S 0 -f header.nocolor > header diff --git a/header b/header new file mode 100644 index 0000000..d3ec095 --- /dev/null +++ b/header @@ -0,0 +1,21 @@ + Welcome to__________________________________ +||  ___        ___                           || +|| |   \      /   |                          || +|| | |\ \    / /| |   _    __     _    _     || +|| | | \ \  / / | |  |_|  |  \   | |  |_|    || +|| | |  \ \/ /  | |   _   |   \  | |   _     || +|| | |   \  /   | |  | |  | |\ \ | |  | |    || +|| | |    \/    | |  | |  | | \ \| |  | |    || +|| | |          | |  | |  | |  \   |  | |    || +|| |_|          |_|  |_|  |_|   \__|  |_|    || +||                                           || +||       =====     By: Mylan COLONNA         || +||      //            And: Joris SCHAFT      || +||     //                                    || +||     \\                                    || +||      =====  ||  ||  ==== ||    ||         || +||          \\ ||  || ||    ||    ||         || +||          // |====| |===  ||    ||         || +||         //  ||  || ||    ||    ||         || +||     =====   ||  ||  ====  ====  ====      || +||___________________________________________|| diff --git a/header.nocolor b/header.nocolor new file mode 100644 index 0000000..bf43ad5 --- /dev/null +++ b/header.nocolor @@ -0,0 +1,21 @@ + Welcome to__________________________________ +|| ___ ___ || +|| | \ / | || +|| | |\ \ / /| | _ __ _ _ || +|| | | \ \ / / | | |_| | \ | | |_| || +|| | | \ \/ / | | _ | \ | | _ || +|| | | \ / | | | | | |\ \ | | | | || +|| | | \/ | | | | | | \ \| | | | || +|| | | | | | | | | \ | | | || +|| |_| |_| |_| |_| \__| |_| || +|| || +|| ===== By: Mylan COLONNA || +|| // And: Joris SCHAFT || +|| // || +|| \\ || +|| ===== || || ==== || || || +|| \\ || || || || || || +|| // |====| |=== || || || +|| // || || || || || || +|| ===== || || ==== ==== ==== || +||___________________________________________|| diff --git a/src/ask_command.c b/src/ask_command.c index 5652910..5b7719a 100644 --- a/src/ask_command.c +++ b/src/ask_command.c @@ -6,7 +6,7 @@ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/23 15:03:23 by mcolonna #+# #+# */ -/* Updated: 2024/04/29 15:11:06 by mcolonna ### ########.fr */ +/* Updated: 2024/05/01 12:46:34 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,7 +16,7 @@ const char *ask_command(const t_memclass mc) { const char *r; - print_str(fatal_error, 1, "( ^.^)> "); + print_str(fatal_error, 1, "\e[1m\e[38;5;45m( ^.^)> \e[0m"); r = read_line(fatal_error, mc, 0); if (r) return (r); diff --git a/src/main.c b/src/main.c index c004707..0182151 100644 --- a/src/main.c +++ b/src/main.c @@ -6,53 +6,15 @@ /* By: mcolonna +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/23 14:33:45 by mcolonna #+# #+# */ -/* Updated: 2024/04/30 16:06:11 by mcolonna ### ########.fr */ +/* Updated: 2024/05/01 11:35:54 by mcolonna ### ########.fr */ /* */ /* ************************************************************************** */ #include "include.h" -// Clean the screen -static void execclear(char *const envp[]) -{ - const t_memclass mc = mem_subclass(fatal_error, g_mc); - t_command command; - - command = parse_command(mc, "clear"); - if (command.error) - return ; - execute_command(mc, command, envp); - mem_freeall(mc); -} - -// Print hi :D -static void print_hi(void) -{ - printf("Welcome to____________________________________\n"); - printf("|| ___ ___ ||\n"); - printf("|| | \\ / | ||\n"); - printf("|| | |\\ \\ / /| | __ __ __ __ ||\n"); - printf("|| | | \\ \\ / / | | |__| ||\\ || |__| ||\n"); - printf("|| | | \\ \\/ / | | __ || \\ || __ ||\n"); - printf("|| | | \\ / | | || || \\ || || ||\n"); - printf("|| | | \\/ | | || || \\ || || ||\n"); - printf("|| | | | | || || \\ || || ||\n"); - printf("|| |_| |_| || || \\|| || ||\n"); - printf("|| _____ ||\n"); - printf("|| / ___| By: Mylan COLONNA ||\n"); - printf("|| \\ \\ And: Joris SCHAFT ||\n"); - printf("|| \\ \\ ||\n"); - printf("|| \\ \\ __ __ __ __ __ ||\n"); - printf("|| \\ \\ || || ||=== || || ||\n"); - printf("|| \\ \\ || || || || || ||\n"); - printf("|| / / ||===|| ||=== || || ||\n"); - printf("|| ___/ / || || || || || ||\n"); - printf("|| |____/ || || ||=== ||=== ||=== ||\n"); - printf("|_____________________________________________|\n\n"); -} - t_memclass g_mc; +// Close the input and output fds of the command. static void close_fds(const t_command *command) { if (command->input_fd != 0) @@ -63,30 +25,46 @@ static void close_fds(const t_command *command) minishell_error("errno"); } +// Execute a command from a string. +static int do_command(char *const envp[], const char *str) +{ + const t_memclass mc = mem_subclass(fatal_error, g_mc); + t_command command; + int r; + + command = parse_command(mc, str); + if (command.error || command.empty) + return (command.error); + r = execute_command(mc, command, envp); + mem_freeall(mc); + close_fds(&command); + return (r); +} + +static void start(char *const envp[]) +{ + do_command(envp, "clear"); + do_command(envp, "cat ./header"); + do_command(envp, "echo"); +} + int main(const int argc, const char *argv[], char *const envp[]) { t_memclass mc; const char *command_str; - t_command command; int errorstatus; (void)argc; (void)argv; g_mc = NULL; g_mc = mem_newclass(fatal_error); - execclear(envp); - print_hi(); + start(envp); errorstatus = 0; while (true) { mc = mem_subclass(fatal_error, g_mc); command_str = ask_command(mc); - command = parse_command(mc, command_str); - if (command.error || command.empty) - continue ; - errorstatus = execute_command(mc, command, envp); - mem_freeall(mc); - close_fds(&command); + do_command(envp, command_str); } return (errorstatus); }