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.
This commit is contained in:
Sergei Morozov 2021-12-26 13:37:13 -08:00 committed by GitHub
parent 1e503745a1
commit 69b5a3535c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,8 +87,13 @@ function __fish_mvn_profiles
sed -n -e '/<profile>/{n; s!^.*<id>\([^<]*\)</id>.*$!\1!; p}' ~/.m2/settings.xml pom.xml 2>/dev/null
end
function __fish_mvn_projects
grep "<module>" 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"