Skip to content

Commit 7f94b33

Browse files
committed
feat: add completions for --manifest-path
1 parent 1d1d646 commit 7f94b33

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
@@ -10,6 +10,7 @@ use crate::util::important_paths::find_root_manifest_for_wd;
1010
use crate::util::interning::InternedString;
1111
use crate::util::is_rustup;
1212
use crate::util::restricted_names;
13+
use crate::util::toml::is_embedded;
1314
use crate::util::{
1415
print_available_benches, print_available_binaries, print_available_examples,
1516
print_available_packages, print_available_tests,
@@ -325,7 +326,21 @@ pub trait CommandExt: Sized {
325326
self._arg(
326327
opt("manifest-path", "Path to Cargo.toml")
327328
.value_name("PATH")
328-
.help_heading(heading::MANIFEST_OPTIONS),
329+
.help_heading(heading::MANIFEST_OPTIONS)
330+
.add(clap_complete::engine::ArgValueCompleter::new(
331+
clap_complete::engine::PathCompleter::any().filter(|path: &Path| {
332+
if path.file_name() == Some(OsStr::new("Cargo.toml")) {
333+
return true;
334+
}
335+
if is_embedded(path) {
336+
return true;
337+
}
338+
if path.is_file() && path.extension().is_none() {
339+
return true;
340+
}
341+
false
342+
}),
343+
)),
329344
)
330345
}
331346

0 commit comments

Comments
 (0)