Skip to content

Commit

Permalink
feat: add completions for --lockfile-path (#15238)
Browse files Browse the repository at this point in the history
### What does this PR try to resolve?

Add auto completion for `cargo build --lockfile-path <TAB>`

Related to #14520

### How should we test and review this PR?

![Screenshot from 2025-02-27
18-38-21](https://github.com/user-attachments/assets/36ae3584-8e1a-4e9e-bab8-fe239c03bb82)
  • Loading branch information
epage authored Feb 28, 2025
2 parents 58cfd96 + 4afa6d7 commit e79bac1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,18 @@ pub trait CommandExt: Sized {
self._arg(
opt("lockfile-path", "Path to Cargo.lock (unstable)")
.value_name("PATH")
.help_heading(heading::MANIFEST_OPTIONS),
.help_heading(heading::MANIFEST_OPTIONS)
.add(clap_complete::engine::ArgValueCompleter::new(
clap_complete::engine::PathCompleter::any().filter(|path: &Path| {
let file_name = match path.file_name() {
Some(name) => name,
None => return false,
};

// allow `Cargo.lock` file
file_name == OsStr::new("Cargo.lock")
}),
)),
)
}

Expand Down

0 comments on commit e79bac1

Please sign in to comment.