interface : fonction print_prompt utilisée dans get_user_input
This commit is contained in:
parent
1fc2c8adbd
commit
fdcaa99feb
2 changed files with 4 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
use crate::command::Command;
|
use crate::command::Command;
|
||||||
use crate::exit_code::ExitCode;
|
use crate::exit_code::ExitCode;
|
||||||
use crate::interface::{get_user_input, print_prompt};
|
use crate::interface::get_user_input;
|
||||||
use crate::parser::parse;
|
use crate::parser::parse;
|
||||||
|
|
||||||
fn exit(code: &ExitCode) {
|
fn exit(code: &ExitCode) {
|
||||||
|
@ -13,7 +13,6 @@ pub fn run() {
|
||||||
let mut current_exit_code = ExitCode::new(0);
|
let mut current_exit_code = ExitCode::new(0);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
print_prompt();
|
|
||||||
let user_input = get_user_input();
|
let user_input = get_user_input();
|
||||||
|
|
||||||
if user_input.is_some() {
|
if user_input.is_some() {
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::io::{stdin, stdout};
|
use std::io::{stdin, stdout};
|
||||||
|
|
||||||
pub fn print_prompt() {
|
fn print_prompt() {
|
||||||
print!("$ ");
|
print!("$ ");
|
||||||
stdout().flush().unwrap();
|
stdout().flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_user_input() -> Option<String> {
|
pub fn get_user_input() -> Option<String> {
|
||||||
|
print_prompt();
|
||||||
|
|
||||||
let mut user_input = String::new();
|
let mut user_input = String::new();
|
||||||
|
|
||||||
let bytes_read = stdin()
|
let bytes_read = stdin()
|
||||||
|
|
Loading…
Reference in a new issue