From 69b5a3535ccf8656d22b844a3d43877d00a17408 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 26 Dec 2021 13:37:13 -0800 Subject: [PATCH] Add basic completion for mvn -pl switch (#8570) This patch introduces basic completion of the -pl|--projects switch for mvn. The implementation is quite naive but it's better than nothing. A more robust implementation would require either scanning the filesystem or running mvn which might slow down completion significantly. This solution can be improved by using an XML parser instead of grep/sed. --- share/completions/mvn.fish | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/completions/mvn.fish b/share/completions/mvn.fish index ea9eb596e..5266c3fad 100644 --- a/share/completions/mvn.fish +++ b/share/completions/mvn.fish @@ -87,8 +87,13 @@ function __fish_mvn_profiles sed -n -e '//{n; s!^.*\([^<]*\).*$!\1!; p}' ~/.m2/settings.xml pom.xml 2>/dev/null end +function __fish_mvn_projects + grep "" pom.xml 2>/dev/null | sed 's/\s*<[^<]*>\(.*\)<[^<]*>/\1/' +end + complete -c mvn -f -r -o P -l activate-profiles -a "(__fish_mvn_profiles)" -d "Comma-delimited list of profiles to activate" +complete -c mvn -f -r -o pl -l projects -a "(__fish_mvn_projects)" -d "Projects to build" #default properties for some plugins / profiles complete -c mvn -o DskipTests -d "Skipping JUnit Tests"