From 9b45835d0f7a26e74dac85a853e34d853875fc61 Mon Sep 17 00:00:00 2001 From: Nordine Bittich Date: Sun, 11 Jun 2023 11:16:23 +0200 Subject: [PATCH] fix regression after supporting tilde --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/cache_command/parser.rs | 12 +++++++++--- src/cache_command/process.rs | 4 ---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9345cb3..2b52639 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "adana" -version = "0.13.28" +version = "0.13.29" dependencies = [ "anyhow", "bincode", diff --git a/Cargo.toml b/Cargo.toml index f49d4af..e8ec08f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "adana" -version = "0.13.28" +version = "0.13.29" edition = "2021" authors = ["Nordine Bittich"] license = "MIT" diff --git a/src/cache_command/parser.rs b/src/cache_command/parser.rs index 6df5895..ab4c58e 100644 --- a/src/cache_command/parser.rs +++ b/src/cache_command/parser.rs @@ -131,7 +131,7 @@ fn cd_command(command: &str) -> Res { map( preceded( tag_no_case(CD), - preceded( + opt(preceded( multispace1, pair( map( @@ -148,9 +148,15 @@ fn cd_command(command: &str) -> Res { }), )), ), - ), + )), ), - |(has_tilde, path)| CacheCommand::Cd { has_tilde, path }, + |op| { + if let Some((has_tilde, path)) = op { + CacheCommand::Cd { has_tilde, path } + } else { + CacheCommand::Cd { has_tilde: false, path: None } + } + }, )(command) } diff --git a/src/cache_command/process.rs b/src/cache_command/process.rs index 029686c..94dc325 100644 --- a/src/cache_command/process.rs +++ b/src/cache_command/process.rs @@ -245,10 +245,6 @@ pub fn process_command( )?; if path_buf.exists() { std::env::set_current_dir(path_buf.as_path())?; - // println!( - // ">> working directory {}", - // LightMagenta.paint(path_buf.to_string_lossy()) - // ); } else { return Err(anyhow::Error::msg(format!( "path {} doesn't exist",