Skip to content

Commit

Permalink
fix: sed + profile (continuation)
Browse files Browse the repository at this point in the history
  • Loading branch information
glhez committed Jul 3, 2016
1 parent 6cef69a commit 66da469
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions bash_completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,29 @@ _mvn()
local plugin_goals_wildfly="wildfly:add-resource|wildfly:deploy|wildfly:deploy-only|wildfly:deploy-artifact|wildfly:redeploy|wildfly:redeploy-only|wildfly:undeploy|wildfly:undeploy-artifact|wildfly:run|wildfly:start|wildfly:shutdown|wildfly:execute-commands"

## some plugin (like jboss-as) has '-' which is not allowed in shell var name, to use '_' then replace
local common_plugins=`compgen -v | \grep "^plugin_goals_.*" | sed -e 's/plugin_goals_//g' -e 's/_/-/g' | tr '\n' '|'`
local common_plugins=`compgen -v | \grep "^plugin_goals_.*" | sed -e 's/plugin_goals_//g' -e 's/_/-/g' -e 's@\n@|@g'`

local options="-Dmaven.test.skip=true|-DskipTests|-DskipITs|-Dtest|-Dit.test|-DfailIfNoTests|-Dmaven.surefire.debug|-DenableCiProfile|-Dpmd.skip=true|-Dcheckstyle.skip=true|-Dtycho.mode=maven|-Dmaven.javadoc.skip=true|-Dgwt.compiler.skip|-Dcobertura.skip=true|-Dfindbugs.skip=true||-DperformRelease=true|-Dgpg.skip=true|-DforkCount"

local profile_settings=`[ -e ~/.m2/settings.xml ] && \grep -e "<profile>" -A 1 ~/.m2/settings.xml | \grep -e "<id>.*</id>" | sed -e 's/.*<id>//' -e 's/<\/id>.*//g' | tr '\n' '|' `

local OIFS=$IFS
local IFS=$'|\n'

if [[ ${cur} == -D* ]] ; then
COMPREPLY=( $(compgen -S ' ' -W "${options}" -- ${cur}) )

elif [[ ${prev} == -P || ${prev} == --activate-profiles ]] ; then
IFS=$OIFS

local profile_settings=`[ -e ~/.m2/settings.xml ] && \grep -e "<profile>" -A 1 ~/.m2/settings.xml | \grep -e "<id>.*</id>" | sed -e 's/.*<id>//' -e 's/<\/id>.*//g' -e 's@\n@|@g' `
local profiles="${profile_settings}|"
for item in ${POM_HIERARCHY[*]}
do
local profile_pom=`[ -e $item ] && \grep -e "<profile>" -A 1 $item | \grep -e "<id>.*</id>" | sed -e 's/.*<id>//' -e 's/<\/id>.*//g' | tr '\n' '|' `
local profile_pom=`[ -e $item ] && \grep -e "<profile>" -A 1 $item | \grep -e "<id>.*</id>" | sed -e 's/.*<id>//' -e 's/<\/id>.*//g' -e 's@\n@|@g' `
local profiles="${profiles}|${profile_pom}"
done

IFS=$'|\n'

if [[ ${cur} == *,* ]] ; then
COMPREPLY=( $(compgen -S ',' -W "${profiles}" -P "${cur%,*}," -- ${cur##*,}) )
else
Expand Down

0 comments on commit 66da469

Please sign in to comment.