From fdcaa99feb238316a0c186f54d148a96a749ae8f Mon Sep 17 00:00:00 2001 From: Ahurac Date: Wed, 17 Apr 2024 10:25:06 +0200 Subject: [PATCH] =?UTF-8?q?interface=20:=20fonction=20print=5Fprompt=20uti?= =?UTF-8?q?lis=C3=A9e=20dans=20get=5Fuser=5Finput?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/control.rs | 3 +-- src/interface.rs | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/control.rs b/src/control.rs index 585a295..3fb17b7 100644 --- a/src/control.rs +++ b/src/control.rs @@ -1,6 +1,6 @@ use crate::command::Command; use crate::exit_code::ExitCode; -use crate::interface::{get_user_input, print_prompt}; +use crate::interface::get_user_input; use crate::parser::parse; fn exit(code: &ExitCode) { @@ -13,7 +13,6 @@ pub fn run() { let mut current_exit_code = ExitCode::new(0); loop { - print_prompt(); let user_input = get_user_input(); if user_input.is_some() { diff --git a/src/interface.rs b/src/interface.rs index 627070d..c537545 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -1,12 +1,14 @@ use std::io::Write; use std::io::{stdin, stdout}; -pub fn print_prompt() { +fn print_prompt() { print!("$ "); stdout().flush().unwrap(); } pub fn get_user_input() -> Option { + print_prompt(); + let mut user_input = String::new(); let bytes_read = stdin()