From 0ffba5c648193a858ae87013db66138c289a94d3 Mon Sep 17 00:00:00 2001 From: Gui Date: Wed, 8 May 2024 12:01:16 -0700 Subject: [PATCH] feat: new `--args` parameter for `fd` an `rg` search (#1013) Co-authored-by: sxyazi --- Cargo.lock | 165 +++++++++++++-------------- yazi-adaptor/Cargo.toml | 2 +- yazi-boot/Cargo.toml | 2 +- yazi-cli/Cargo.toml | 8 +- yazi-config/Cargo.toml | 4 +- yazi-core/Cargo.toml | 7 +- yazi-core/src/tab/commands/search.rs | 25 ++-- yazi-dds/Cargo.toml | 8 +- yazi-fm/Cargo.toml | 4 +- yazi-plugin/Cargo.toml | 8 +- yazi-plugin/src/external/fd.rs | 7 +- yazi-plugin/src/external/rg.rs | 4 +- yazi-proxy/Cargo.toml | 2 +- yazi-proxy/src/app.rs | 13 +++ yazi-scheduler/Cargo.toml | 4 +- yazi-shared/Cargo.toml | 4 +- 16 files changed, 146 insertions(+), 121 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c8f84bf0..8b95c82c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -120,9 +120,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" [[package]] name = "arc-swap" @@ -141,9 +141,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" @@ -678,7 +678,7 @@ checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.4.1", "windows-sys 0.52.0", ] @@ -922,7 +922,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core", + "windows-core 0.52.0", ] [[package]] @@ -1114,9 +1114,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -1418,15 +1418,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.5.1", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -1601,6 +1601,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags 2.5.0", +] + [[package]] name = "redox_users" version = "0.4.5" @@ -1695,9 +1704,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.199" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" +checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" dependencies = [ "serde_derive", ] @@ -1714,9 +1723,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.199" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" +checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" dependencies = [ "proc-macro2", "quote", @@ -1725,9 +1734,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -1829,9 +1838,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -2091,9 +2100,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", @@ -2208,9 +2217,9 @@ dependencies = [ [[package]] name = "trash" -version = "4.1.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a1a7a9a17d3b004898be42be29a4c18d5a4cf008b5cdf72d69b1945dfcb158a" +checksum = "c254b119cf49bdde3dfef21b1dc492dc8026b75566ca24aa77993eccd7cbc1b5" dependencies = [ "chrono", "libc", @@ -2463,11 +2472,12 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.44.0" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b" +checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" dependencies = [ - "windows-targets 0.42.2", + "windows-core 0.56.0", + "windows-targets 0.52.5", ] [[package]] @@ -2479,6 +2489,49 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "windows-core" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-result", + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-implement" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "windows-interface" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "windows-result" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "749f0da9cc72d82e600d8d2e44cadd0b9eedb9038f71a1c58556ac1c5791813b" +dependencies = [ + "windows-targets 0.52.5", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -2497,21 +2550,6 @@ dependencies = [ "windows-targets 0.52.5", ] -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - [[package]] name = "windows-targets" version = "0.48.5" @@ -2543,12 +2581,6 @@ dependencies = [ "windows_x86_64_msvc 0.52.5", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -2561,12 +2593,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -2579,12 +2605,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -2603,12 +2623,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -2621,12 +2635,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -2639,12 +2647,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -2657,12 +2659,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -2777,6 +2773,7 @@ dependencies = [ "regex", "scopeguard", "serde", + "shell-words", "tokio", "tokio-stream", "tokio-util", diff --git a/yazi-adaptor/Cargo.toml b/yazi-adaptor/Cargo.toml index c0b04f71..eb0efecd 100644 --- a/yazi-adaptor/Cargo.toml +++ b/yazi-adaptor/Cargo.toml @@ -13,7 +13,7 @@ yazi-config = { path = "../yazi-config", version = "0.2.5" } yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies -anyhow = "1.0.82" +anyhow = "1.0.83" arc-swap = "1.7.1" base64 = "0.22.1" color_quant = "1.1.0" diff --git a/yazi-boot/Cargo.toml b/yazi-boot/Cargo.toml index 0478716a..56c34d56 100644 --- a/yazi-boot/Cargo.toml +++ b/yazi-boot/Cargo.toml @@ -15,7 +15,7 @@ yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies clap = { version = "4.5.4", features = [ "derive" ] } -serde = { version = "1.0.199", features = [ "derive" ] } +serde = { version = "1.0.201", features = [ "derive" ] } [build-dependencies] clap = { version = "4.5.4", features = [ "derive" ] } diff --git a/yazi-cli/Cargo.toml b/yazi-cli/Cargo.toml index b7d0ee19..93d7cdf7 100644 --- a/yazi-cli/Cargo.toml +++ b/yazi-cli/Cargo.toml @@ -13,21 +13,21 @@ yazi-dds = { path = "../yazi-dds", version = "0.2.5" } yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies -anyhow = "1.0.82" +anyhow = "1.0.83" clap = { version = "4.5.4", features = [ "derive" ] } crossterm = "0.27.0" md-5 = "0.10.6" -serde_json = "1.0.116" +serde_json = "1.0.117" tokio = { version = "1.37.0", features = [ "full" ] } toml_edit = "0.22.12" [build-dependencies] -anyhow = "1.0.82" +anyhow = "1.0.83" clap = { version = "4.5.4", features = [ "derive" ] } clap_complete = "4.5.2" clap_complete_fig = "4.5.0" clap_complete_nushell = "4.5.1" -serde_json = "1.0.116" +serde_json = "1.0.117" vergen = { version = "8.3.1", features = [ "build", "git", "gitcl" ] } [[bin]] diff --git a/yazi-config/Cargo.toml b/yazi-config/Cargo.toml index 764bc2c8..11b67051 100644 --- a/yazi-config/Cargo.toml +++ b/yazi-config/Cargo.toml @@ -12,13 +12,13 @@ repository = "https://github.com/sxyazi/yazi" yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies -anyhow = "1.0.82" +anyhow = "1.0.83" arc-swap = "1.7.1" crossterm = "0.27.0" globset = "0.4.14" indexmap = "2.2.6" ratatui = "=0.26.1" -serde = { version = "1.0.199", features = [ "derive" ] } +serde = { version = "1.0.201", features = [ "derive" ] } shell-words = "1.1.0" toml = { version = "0.8.12", features = [ "preserve_order" ] } validator = { version = "0.18.1", features = [ "derive" ] } diff --git a/yazi-core/Cargo.toml b/yazi-core/Cargo.toml index c60bde23..5c44a58b 100644 --- a/yazi-core/Cargo.toml +++ b/yazi-core/Cargo.toml @@ -19,7 +19,7 @@ yazi-scheduler = { path = "../yazi-scheduler", version = "0.2.5" } yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies -anyhow = "1.0.82" +anyhow = "1.0.83" bitflags = "2.5.0" crossterm = "0.27.0" futures = "0.3.30" @@ -28,11 +28,12 @@ parking_lot = "0.12.2" ratatui = "=0.26.1" regex = "1.10.4" scopeguard = "1.2.0" -serde = "1.0.199" +serde = "1.0.201" tokio = { version = "1.37.0", features = [ "full" ] } tokio-stream = "0.1.15" -tokio-util = "0.7.10" +tokio-util = "0.7.11" unicode-width = "0.1.12" +shell-words = "1.1.0" # Logging tracing = { version = "0.1.40", features = [ "max_level_debug", "release_max_level_warn" ] } diff --git a/yazi-core/src/tab/commands/search.rs b/yazi-core/src/tab/commands/search.rs index d4119e90..700f5423 100644 --- a/yazi-core/src/tab/commands/search.rs +++ b/yazi-core/src/tab/commands/search.rs @@ -5,7 +5,7 @@ use tokio::pin; use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt}; use yazi_config::popup::InputCfg; use yazi_plugin::external; -use yazi_proxy::{InputProxy, ManagerProxy, TabProxy}; +use yazi_proxy::{AppProxy, InputProxy, ManagerProxy, TabProxy}; use yazi_shared::{event::Cmd, fs::FilesOp, render}; use crate::tab::Tab; @@ -39,15 +39,26 @@ impl Display for OptType { pub struct Opt { pub type_: OptType, + pub args: Vec, } -impl From for Opt { - fn from(mut c: Cmd) -> Self { Self { type_: c.take_first_str().unwrap_or_default().into() } } +impl TryFrom for Opt { + type Error = (); + + fn try_from(mut c: Cmd) -> Result { + Ok(Self { + type_: c.take_first_str().unwrap_or_default().into(), + args: shell_words::split(c.str("args").unwrap_or_default()).map_err(|_| ())?, + }) + } } impl Tab { - pub fn search(&mut self, opt: impl Into) { - let opt = opt.into() as Opt; + pub fn search(&mut self, opt: impl TryInto) { + let Ok(opt) = opt.try_into() else { + return AppProxy::notify_error("Invalid `search` option", "Failed to parse search option"); + }; + if opt.type_ == OptType::None { return self.search_stop(); } @@ -65,9 +76,9 @@ impl Tab { cwd = cwd.into_search(subject.clone()); let rx = if opt.type_ == OptType::Rg { - external::rg(external::RgOpt { cwd: cwd.clone(), hidden, subject }) + external::rg(external::RgOpt { cwd: cwd.clone(), hidden, subject, args: opt.args }) } else { - external::fd(external::FdOpt { cwd: cwd.clone(), hidden, glob: false, subject }) + external::fd(external::FdOpt { cwd: cwd.clone(), hidden, subject, args: opt.args }) }?; let rx = UnboundedReceiverStream::new(rx).chunks_timeout(1000, Duration::from_millis(300)); diff --git a/yazi-dds/Cargo.toml b/yazi-dds/Cargo.toml index e5ec8fec..5c6590e1 100644 --- a/yazi-dds/Cargo.toml +++ b/yazi-dds/Cargo.toml @@ -17,14 +17,14 @@ yazi-boot = { path = "../yazi-boot", version = "0.2.5" } yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies -anyhow = "1.0.82" +anyhow = "1.0.83" mlua = { version = "0.9.7", features = [ "lua54" ] } parking_lot = "0.12.2" -serde = { version = "1.0.199", features = [ "derive" ] } -serde_json = "1.0.116" +serde = { version = "1.0.201", features = [ "derive" ] } +serde_json = "1.0.117" tokio = { version = "1.37.0", features = [ "full" ] } tokio-stream = "0.1.15" -tokio-util = "0.7.10" +tokio-util = "0.7.11" [target."cfg(unix)".dependencies] uzers = "0.12.0" diff --git a/yazi-fm/Cargo.toml b/yazi-fm/Cargo.toml index 409e37cf..f6410dfe 100644 --- a/yazi-fm/Cargo.toml +++ b/yazi-fm/Cargo.toml @@ -23,7 +23,7 @@ yazi-proxy = { path = "../yazi-proxy", version = "0.2.5" } yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies -anyhow = "1.0.82" +anyhow = "1.0.83" better-panic = "0.3.0" crossterm = { version = "0.27.0", features = [ "event-stream" ] } fdlimit = "0.3.0" @@ -33,7 +33,7 @@ ratatui = "=0.26.1" scopeguard = "1.2.0" syntect = { version = "5.2.0", default-features = false, features = [ "parsing", "plist-load", "regex-onig" ] } tokio = { version = "1.37.0", features = [ "full" ] } -tokio-util = "0.7.10" +tokio-util = "0.7.11" # Logging tracing = { version = "0.1.40", features = [ "max_level_debug", "release_max_level_warn" ] } diff --git a/yazi-plugin/Cargo.toml b/yazi-plugin/Cargo.toml index 4122648b..24778d07 100644 --- a/yazi-plugin/Cargo.toml +++ b/yazi-plugin/Cargo.toml @@ -22,7 +22,7 @@ yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies ansi-to-tui = "3.1.0" -anyhow = "1.0.82" +anyhow = "1.0.83" base64 = "0.22.1" crossterm = "0.27.0" futures = "0.3.30" @@ -30,13 +30,13 @@ md-5 = "0.10.6" mlua = { version = "0.9.7", features = [ "lua54", "serialize", "macros", "async" ] } parking_lot = "0.12.2" ratatui = "=0.26.1" -serde = "1.0.199" -serde_json = "1.0.116" +serde = "1.0.201" +serde_json = "1.0.117" shell-escape = "0.1.5" shell-words = "1.1.0" syntect = { version = "5.2.0", default-features = false, features = [ "parsing", "plist-load", "regex-onig" ] } tokio = { version = "1.37.0", features = [ "full" ] } -tokio-util = "0.7.10" +tokio-util = "0.7.11" unicode-width = "0.1.12" yazi-prebuild = "0.1.2" diff --git a/yazi-plugin/src/external/fd.rs b/yazi-plugin/src/external/fd.rs index 4fced261..30c4261e 100644 --- a/yazi-plugin/src/external/fd.rs +++ b/yazi-plugin/src/external/fd.rs @@ -7,17 +7,18 @@ use yazi_shared::fs::{File, Url}; pub struct FdOpt { pub cwd: Url, pub hidden: bool, - pub glob: bool, pub subject: String, + pub args: Vec, } pub fn fd(opt: FdOpt) -> Result> { let mut child = Command::new("fd") .arg("--base-directory") .arg(&opt.cwd) + .arg("--regex") .args(if opt.hidden { ["--hidden", "--no-ignore"] } else { ["--no-hidden", "--ignore"] }) - .arg(if opt.glob { "--glob" } else { "--regex" }) - .arg(&opt.subject) + .args(opt.args) + .arg(opt.subject) .kill_on_drop(true) .stdout(Stdio::piped()) .stderr(Stdio::null()) diff --git a/yazi-plugin/src/external/rg.rs b/yazi-plugin/src/external/rg.rs index b37a3235..d5b4b63c 100644 --- a/yazi-plugin/src/external/rg.rs +++ b/yazi-plugin/src/external/rg.rs @@ -8,6 +8,7 @@ pub struct RgOpt { pub cwd: Url, pub hidden: bool, pub subject: String, + pub args: Vec, } pub fn rg(opt: RgOpt) -> Result> { @@ -15,7 +16,8 @@ pub fn rg(opt: RgOpt) -> Result> { .current_dir(&opt.cwd) .args(["--color=never", "--files-with-matches", "--smart-case"]) .args(if opt.hidden { ["--hidden", "--no-ignore"] } else { ["--no-hidden", "--ignore"] }) - .arg(&opt.subject) + .args(opt.args) + .arg(opt.subject) .kill_on_drop(true) .stdout(Stdio::piped()) .stderr(Stdio::null()) diff --git a/yazi-proxy/Cargo.toml b/yazi-proxy/Cargo.toml index 09f5a61c..d37998af 100644 --- a/yazi-proxy/Cargo.toml +++ b/yazi-proxy/Cargo.toml @@ -17,6 +17,6 @@ yazi-config = { path = "../yazi-config", version = "0.2.5" } yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies -anyhow = "1.0.82" +anyhow = "1.0.83" mlua = { version = "0.9.7", features = [ "lua54" ] } tokio = { version = "1.37.0", features = [ "full" ] } diff --git a/yazi-proxy/src/app.rs b/yazi-proxy/src/app.rs index add88327..fcdcb470 100644 --- a/yazi-proxy/src/app.rs +++ b/yazi-proxy/src/app.rs @@ -37,4 +37,17 @@ impl AppProxy { Layer::App )); } + + #[inline] + pub fn notify_error(title: &str, content: &str) { + emit!(Call( + Cmd::new("notify").with_any("option", NotifyOpt { + title: title.to_owned(), + content: content.to_owned(), + level: NotifyLevel::Error, + timeout: Duration::from_secs(10), + }), + Layer::App + )); + } } diff --git a/yazi-scheduler/Cargo.toml b/yazi-scheduler/Cargo.toml index 85e8d918..ca1a1122 100644 --- a/yazi-scheduler/Cargo.toml +++ b/yazi-scheduler/Cargo.toml @@ -16,7 +16,7 @@ yazi-proxy = { path = "../yazi-proxy", version = "0.2.5" } yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies -anyhow = "1.0.82" +anyhow = "1.0.83" async-priority-channel = "0.2.0" futures = "0.3.30" parking_lot = "0.12.2" @@ -30,4 +30,4 @@ tracing = { version = "0.1.40", features = [ "max_level_debug", "release_max_lev libc = "0.2.154" [target.'cfg(not(target_os = "android"))'.dependencies] -trash = "4.1.0" +trash = "4.1.1" diff --git a/yazi-shared/Cargo.toml b/yazi-shared/Cargo.toml index b2a14a84..098b132d 100644 --- a/yazi-shared/Cargo.toml +++ b/yazi-shared/Cargo.toml @@ -9,7 +9,7 @@ homepage = "https://yazi-rs.github.io" repository = "https://github.com/sxyazi/yazi" [dependencies] -anyhow = "1.0.82" +anyhow = "1.0.83" bitflags = "2.5.0" crossterm = "0.27.0" dirs = "5.0.1" @@ -19,7 +19,7 @@ parking_lot = "0.12.2" percent-encoding = "2.3.1" ratatui = "=0.26.1" regex = "1.10.4" -serde = { version = "1.0.199", features = [ "derive" ] } +serde = { version = "1.0.201", features = [ "derive" ] } tokio = { version = "1.37.0", features = [ "full" ] } # Logging