From e6ed91d0efab436c8a1ca4b6f701b6a9a4d96ccd Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Tue, 11 Apr 2023 20:45:11 +0200 Subject: Refactoring, move where whitespace is handled --- src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index acb6df2..99b755d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,7 @@ fn main_inner() -> Result<(), ShackleError> { let args = Args::parse(); match args.command { Some(user_input) => { - run_command(user_input)?; + run_command(&user_input)?; } None => { run_interactive_loop()?; @@ -36,9 +36,10 @@ fn run_interactive_loop() -> Result<(), ShackleError> { let mut rl = DefaultEditor::new()?; loop { let readline = rl.readline("> "); - match readline { + match readline.as_ref().map(|user_input| user_input.trim()) { + Ok("") => {} Ok(user_input) => { - rl.add_history_entry(user_input.as_str())?; + rl.add_history_entry(user_input)?; match run_command(user_input) { Ok(control_flow) => { if control_flow.is_break() { -- cgit v1.2.3