diff --git a/Makefile b/Makefile index 3483478..8904511 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,10 @@ ifeq ($(sanitize), true) CFLAGS += -fsanitize=address,undefined -g3 endif +### READLINE FLAGS ############################################################## + +RDL_FLAGS += -lreadline + ### COLORS ##################################################################### GREEN := \033[0;32m @@ -70,7 +74,7 @@ all: $(NAME) $(NAME): $(LIBFT) $(OBJS) @echo "$(BLUE)Compiling $(NAME)...$(WHITE)" - @$(CC) $(CFLAGS) $(OBJS) -o $(NAME) $(LIBFT) -I $(PATH_INCLUDES) -I $(PATH_INCLUDES_LIBFT) + @$(CC) $(CFLAGS) $(RDL_FLAGS) $(OBJS) -o $(NAME) $(LIBFT) -I $(PATH_INCLUDES) -I $(PATH_INCLUDES_LIBFT) @echo "$(GREEN)$(NAME) Compiled !$(WHITE)" $(OBJS): $(PATH_OBJS)%.o: %.c $(HEADERS) diff --git a/e2e/edit_text_in_prompt/edit_text_in_prompt.test.py b/e2e/edit_text_in_prompt/edit_text_in_prompt.test.py new file mode 100644 index 0000000..1d4fff6 --- /dev/null +++ b/e2e/edit_text_in_prompt/edit_text_in_prompt.test.py @@ -0,0 +1,18 @@ +import pexpect + +# Lancer Minishell +child = pexpect.spawn('./minishell') + +# Vérifier que le prompt s'affiche +child.expect("SDF> ") + +# Envoyer une commande +child.sendline("echo Hello World") + +# Lire la sortie et vérifier +child.expect("Hello World") +print("Test passed: 'echo Hello World' executed correctly.") + +# Quitter le shell +child.sendcontrol('d') +child.expect(pexpect.EOF) diff --git a/includes/minishell.h b/includes/minishell.h index ff84826..f35aa28 100644 --- a/includes/minishell.h +++ b/includes/minishell.h @@ -3,18 +3,28 @@ /* ::: :::::::: */ /* minishell.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: hucherea +#+ +:+ +#+ */ +/* By: tchobert +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/09 16:11:56 by hucherea #+# #+# */ -/* Updated: 2024/12/10 11:08:32 by hucherea ### ########.fr */ +/* Updated: 2024/12/10 14:32:57 by tchobert ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef MINISHELL_H # define MINISHELL_H +// INCLUDES // + +# include "libft.h" + # include +# include +# include +//# include + +// DEFINES // -# define LOOP 1 +# define MSH_LOOP 1 +# define MSH_PROMPT "SDF$> " #endif diff --git a/srcs/main.c b/srcs/main.c index ef1410b..80461b4 100644 --- a/srcs/main.c +++ b/srcs/main.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* main.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: hucherea +#+ +:+ +#+ */ +/* By: tchobert +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/09 16:11:39 by hucherea #+# #+# */ -/* Updated: 2024/12/10 10:39:56 by hucherea ### ########.fr */ +/* Updated: 2024/12/10 14:32:35 by tchobert ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,8 +14,13 @@ static int core_routine(void) { - while (LOOP) + char *user_input_line; + + user_input_line = NULL; + while (MSH_LOOP) { + user_input_line = readline(MSH_PROMPT); + free(user_input_line); } return (EXIT_SUCCESS); }