From 3773baf1f337da1598509b8f5ab8f3a889f171b5 Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Mon, 15 Nov 2021 21:01:18 -0500 Subject: [PATCH] Use `cargo run --example` to get list of examples This behavior matches the way completions are found for `cargo run`, `cargo test`, etc., and is more robust and correct compared to looking at filenames. --- share/completions/cargo.fish | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/share/completions/cargo.fish b/share/completions/cargo.fish index ded85ed35..2ab4a3726 100644 --- a/share/completions/cargo.fish +++ b/share/completions/cargo.fish @@ -12,17 +12,9 @@ for x in bench b build rustc t test complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l test -a "(cargo test --test 2>&1 | string replace -rf '^\s+' '')" end -function __list_cargo_examples - if not test -d ./examples - return - end - - find ./examples -mindepth 1 -maxdepth 1 -type f -name "*.rs" -or -type d \ - | string replace -r './examples/(.*?)(?:.rs)?$' '$1' -end for x in bench b build r run rustc t test complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l bin -a "(cargo run --bin 2>&1 | string replace -rf '^\s+' '')" - complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l example -a "(__list_cargo_examples)" + complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l example -a "(cargo run --example 2>&1 | string replace -rf '^\s+' '')" end function __fish_cargo_packages