Skip to content

Commit e79bac1

Browse files
authored
feat: add completions for --lockfile-path (#15238)
### 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)
2 parents 58cfd96 + 4afa6d7 commit e79bac1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/cargo/util/command_prelude.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,18 @@ pub trait CommandExt: Sized {
345345
self._arg(
346346
opt("lockfile-path", "Path to Cargo.lock (unstable)")
347347
.value_name("PATH")
348-
.help_heading(heading::MANIFEST_OPTIONS),
348+
.help_heading(heading::MANIFEST_OPTIONS)
349+
.add(clap_complete::engine::ArgValueCompleter::new(
350+
clap_complete::engine::PathCompleter::any().filter(|path: &Path| {
351+
let file_name = match path.file_name() {
352+
Some(name) => name,
353+
None => return false,
354+
};
355+
356+
// allow `Cargo.lock` file
357+
file_name == OsStr::new("Cargo.lock")
358+
}),
359+
)),
349360
)
350361
}
351362

0 commit comments

Comments
 (0)