diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a89e66dd..789da9e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,6 +35,8 @@ jobs: uses: Swatinem/rust-cache@v2 - name: Build + env: + YAZI_GEN_COMPLETIONS: true run: cargo build --release --locked --target ${{ matrix.target }} - name: Pack artifacts [Linux & macOS] diff --git a/yazi-config/build.rs b/yazi-config/build.rs index d34bdbbb..c46a35b3 100644 --- a/yazi-config/build.rs +++ b/yazi-config/build.rs @@ -1,12 +1,16 @@ #[path = "src/boot/cli.rs"] mod cli; -use std::{fs, io}; +use std::{env, fs, io}; use clap::CommandFactory; use clap_complete::{generate_to, Shell}; fn main() -> io::Result<()> { + if env::var_os("YAZI_GEN_COMPLETIONS").is_none() { + return Ok(()); + } + let cmd = &mut cli::Args::command(); let bin = "yazi"; let out = "completions"; @@ -19,6 +23,5 @@ fn main() -> io::Result<()> { 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(()) }