mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
feat: add completions for --lockfile-path
This commit is contained in:
parent
7ea222d21d
commit
ad2b1ee7d6
@ -345,7 +345,22 @@ pub trait CommandExt: Sized {
|
|||||||
self._arg(
|
self._arg(
|
||||||
opt("lockfile-path", "Path to Cargo.lock (unstable)")
|
opt("lockfile-path", "Path to Cargo.lock (unstable)")
|
||||||
.value_name("PATH")
|
.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")
|
||||||
|
}),
|
||||||
|
)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user