Skip to content

Commit ad2b1ee

Browse files
committed
feat: add completions for --lockfile-path
1 parent 7ea222d commit ad2b1ee

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/cargo/util/command_prelude.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,22 @@ 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 directories
357+
if path.is_dir() {
358+
return true;
359+
}
360+
// allow `Cargo.lock` file
361+
file_name == OsStr::new("Cargo.lock")
362+
}),
363+
)),
349364
)
350365
}
351366

0 commit comments

Comments
 (0)