diff --git a/Cargo.lock b/Cargo.lock index 96d3ef8f4..461861706 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1554,9 +1554,9 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcb12f8fbf6c62614b0d56eb352af54f6a22410c3b079eb53ee93c7b97dd31d8" +checksum = "a564a852040e82671dc50a37d88f3aa83bbc690dfc6844cfe7a2591620206a80" dependencies = [ "bitflags 2.5.0", "cassowary", @@ -1848,12 +1848,12 @@ dependencies = [ [[package]] name = "stability" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd1b177894da2a2d9120208c3386066af06a488255caabc5de8ddca22dbc3ce" +checksum = "2ff9eaf853dec4c8802325d8b6d3dffa86cc707fd7a1a4cdbf416e13b061787a" dependencies = [ "quote", - "syn 1.0.109", + "syn 2.0.58", ] [[package]] @@ -1903,7 +1903,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", - "quote", "unicode-ident", ] @@ -2724,6 +2723,9 @@ version = "0.2.4" dependencies = [ "anyhow", "clap", + "clap_complete", + "clap_complete_fig", + "clap_complete_nushell", "tokio", "yazi-dds", ] diff --git a/scripts/build.sh b/scripts/build.sh index 2840e1037..68f9b901a 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -10,13 +10,15 @@ rustup toolchain install stable --profile minimal rustup target add "$1" # Build for the target -cargo build --release --locked --target "$1" +cargo build -p yazi-cli --release --locked --target "$1" +cargo build -p yazi-fm --release --locked --target "$1" # Create the artifact -mkdir "$ARTIFACT_NAME" +mkdir -p "$ARTIFACT_NAME/completions" cp "target/$1/release/ya" "$ARTIFACT_NAME" cp "target/$1/release/yazi" "$ARTIFACT_NAME" -cp -r yazi-boot/completions "$ARTIFACT_NAME" +cp yazi-cli/completions/* "$ARTIFACT_NAME/completions" +cp yazi-boot/completions/* "$ARTIFACT_NAME/completions" cp README.md LICENSE "$ARTIFACT_NAME" # Zip the artifact diff --git a/yazi-adaptor/Cargo.toml b/yazi-adaptor/Cargo.toml index 0c170e05f..2b0ca2105 100644 --- a/yazi-adaptor/Cargo.toml +++ b/yazi-adaptor/Cargo.toml @@ -22,7 +22,7 @@ futures = "0.3.30" image = "0.24.9" imagesize = "0.12.0" kamadak-exif = "0.5.5" -ratatui = "0.26.1" +ratatui = "0.26.2" tokio = { version = "1.37.0", features = [ "full" ] } # Logging diff --git a/yazi-cli/Cargo.toml b/yazi-cli/Cargo.toml index 374aba3e6..a90aac131 100644 --- a/yazi-cli/Cargo.toml +++ b/yazi-cli/Cargo.toml @@ -9,13 +9,19 @@ homepage = "https://yazi-rs.github.io" repository = "https://github.com/sxyazi/yazi" [dependencies] -yazi-dds = { path = "../yazi-dds", version = "0.2.4" } +yazi-dds = { path = "../yazi-dds", version = "0.2.4" } # External dependencies anyhow = "1.0.82" clap = { version = "4.5.4", features = [ "derive" ] } tokio = { version = "1.37.0", features = [ "full" ] } +[build-dependencies] +clap = { version = "4.5.4", features = [ "derive" ] } +clap_complete = "4.5.2" +clap_complete_nushell = "4.5.1" +clap_complete_fig = "4.5.0" + [[bin]] name = "ya" path = "src/main.rs" diff --git a/yazi-cli/build.rs b/yazi-cli/build.rs new file mode 100644 index 000000000..f01b5d0f9 --- /dev/null +++ b/yazi-cli/build.rs @@ -0,0 +1,28 @@ +#[path = "src/args.rs"] +mod args; + +use std::{env, error::Error}; + +use clap::CommandFactory; +use clap_complete::{generate_to, Shell}; + +fn main() -> Result<(), Box> { + if env::var_os("YAZI_GEN_COMPLETIONS").is_none() { + return Ok(()); + } + + let cmd = &mut args::Args::command(); + let bin = "ya"; + let out = "completions"; + + std::fs::create_dir_all(out)?; + generate_to(Shell::Bash, cmd, bin, out)?; + generate_to(Shell::Fish, cmd, bin, out)?; + generate_to(Shell::Zsh, cmd, bin, out)?; + generate_to(Shell::Elvish, cmd, bin, out)?; + generate_to(Shell::PowerShell, cmd, bin, out)?; + generate_to(clap_complete_nushell::Nushell, cmd, bin, out)?; + generate_to(clap_complete_fig::Fig, cmd, bin, out)?; + + Ok(()) +} diff --git a/yazi-config/Cargo.toml b/yazi-config/Cargo.toml index f76f69aaa..fbe0a107f 100644 --- a/yazi-config/Cargo.toml +++ b/yazi-config/Cargo.toml @@ -17,7 +17,7 @@ arc-swap = "1.7.1" crossterm = "0.27.0" globset = "0.4.14" indexmap = "2.2.6" -ratatui = "0.26.1" +ratatui = "0.26.2" serde = { version = "1.0.197", features = [ "derive" ] } shell-words = "1.1.0" toml = { version = "0.8.12", features = [ "preserve_order" ] } diff --git a/yazi-core/Cargo.toml b/yazi-core/Cargo.toml index a73f9aec4..8a60d2ae9 100644 --- a/yazi-core/Cargo.toml +++ b/yazi-core/Cargo.toml @@ -26,7 +26,7 @@ crossterm = "0.27.0" futures = "0.3.30" notify = { version = "6.1.1", default-features = false, features = [ "macos_fsevent" ] } parking_lot = "0.12.1" -ratatui = "0.26.1" +ratatui = "0.26.2" regex = "1.10.4" scopeguard = "1.2.0" serde = "1.0.197" diff --git a/yazi-core/src/manager/commands/rename.rs b/yazi-core/src/manager/commands/rename.rs index e1bd73841..af0c28ee7 100644 --- a/yazi-core/src/manager/commands/rename.rs +++ b/yazi-core/src/manager/commands/rename.rs @@ -57,6 +57,10 @@ impl Manager { return; }; + if name.is_empty() { + return; + } + let new = hovered.parent().unwrap().join(name); if opt.force || !accessible(&new).await { Self::rename_do(tab, hovered, Url::from(new)).await.ok(); diff --git a/yazi-fm/Cargo.toml b/yazi-fm/Cargo.toml index 47e6b8cf4..3a54eb177 100644 --- a/yazi-fm/Cargo.toml +++ b/yazi-fm/Cargo.toml @@ -25,7 +25,7 @@ crossterm = { version = "0.27.0", features = [ "event-stream" ] } fdlimit = "0.3.0" futures = "0.3.30" mlua = { version = "0.9.7", features = [ "lua54", "vendored" ] } -ratatui = "0.26.1" +ratatui = "0.26.2" 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" ] } diff --git a/yazi-plugin/Cargo.toml b/yazi-plugin/Cargo.toml index e294b6cad..16395459d 100644 --- a/yazi-plugin/Cargo.toml +++ b/yazi-plugin/Cargo.toml @@ -23,7 +23,7 @@ futures = "0.3.30" md-5 = "0.10.6" mlua = { version = "0.9.7", features = [ "lua54", "vendored", "serialize", "macros", "async" ] } parking_lot = "0.12.1" -ratatui = "0.26.1" +ratatui = "0.26.2" serde = "1.0.197" serde_json = "1.0.115" shell-escape = "0.1.5" diff --git a/yazi-shared/Cargo.toml b/yazi-shared/Cargo.toml index a76cc93e8..a02445bab 100644 --- a/yazi-shared/Cargo.toml +++ b/yazi-shared/Cargo.toml @@ -16,7 +16,7 @@ dirs = "5.0.1" futures = "0.3.30" parking_lot = "0.12.1" percent-encoding = "2.3.1" -ratatui = "0.26.1" +ratatui = "0.26.2" regex = "1.10.4" serde = "1.0.197" tokio = { version = "1.37.0", features = [ "full" ] }