feat: add completions for --lockfile-path

This commit is contained in:
utnim2 2025-02-27 18:38:55 +05:30
parent 7ea222d21d
commit ad2b1ee7d6

View File

@ -345,7 +345,22 @@ 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 directories
if path.is_dir() {
return true;
}
// allow `Cargo.lock` file
file_name == OsStr::new("Cargo.lock")
}),
)),
)
}