Takashi,

I got -D args working with the following brute force method. Since it works, I haven't gone back to simplify. I could probably get rid of the if/else by adding the -- escape to your original compgen. That alone made me wonder how you got -D to complete since it wasn't escaped going into compgen.

However, your reply still makes it sound like something is being automated to get the -D arguments from the plugin:goal. As you see in my code, I hard coded the values. Is that consistent with what you have done locally?

If I can get this working, maybe I'll start using "mvn help:describe" more on the command line rather than plugging in keywords into google. I can never remember those long list of -D arguments for many of the commands.

thanks,
jim

_m2_make_archetype_args()
{
 opts="$opts -DlocalRepository="
 opts="$opts -DpackageName="
...

_m2_complete()
{
 local cur goals opts cmd
...
 goal=${COMP_WORDS[1]}

...
 goal=`echo $goal | sed 's/\\\\//g'`
 case "${goal}" in
    archetype:create)
          _m2_make_archetype_args
          ;;
  esac


 cur=`echo $cur | sed 's/\\\\//g'`
 if [ `echo "${cur}" | egrep ^- | wc -l` -ge 1 ]; then
     COMPREPLY=($(compgen -W "${opts}" -- ${cur} | sed 's/\\\\//g') )
 else
     COMPREPLY=($(compgen -W "${goals}" ${cur} | sed 's/\\\\//g') )
 fi
}



Takashi Nishigaya wrote:

hi jim,

> I tried this and it worked; almost. I assume you have to manually edit
> the script to add the commands you care about. There is no magical way
> to inspect the plugins available to the current pom.xml and kick out a
> list of their targets; right?

yes, it is difficult to inspect more suitable goals/targets candidates from your development environment like the current pom.xml. The current script is not perfect and not maintenance-free. You need to edit m2 file to fit your settings.

> However, beyond the <plugin>:<target> functionality, how did you
> get -D arguments working for your blog entry?

Did you mean that the inspection of -D arguments didn't work?
The parameter list for the plugin specified in the command line is retrieved by invoking mvn help:describe internally and cached in ~/.bash/completion/m2/. Therefore, you must be online, when you specify the plugin which parameter list is not cached yet.

Or, you may need to hit more <TAB>. ;-) More precisely,

$ mvn archetype:create <TAB>-D<TAB><TAB>

This is the behavior of bash completion, not my script.

thanks,
Takashi Nishigaya

jim stafford wrote:

Takashi.

I tried this and it worked; almost. I assume you have to manually edit the script to add the commands you care about. There is no magical way to inspect the plugins available to the current pom.xml and kick out a list of their targets; right?

I'm fine with editing the script (do you have a more fully populated one?). However, beyond the <plugin>:<target> functionality, how did you get -D arguments working for your blog entry?

$ mvn archetype:create <TAB>-D<TAB>
-DarchetypeArtifactId=
-DarchetypeArtifactId=maven-archetype-archetype
-DarchetypeArtifactId=maven-archetype-j2ee-simple
...

thanks,
jim



Takashi Nishigaya wrote:

Hi ccadete,

try my bash completion script:

http://blogs.sun.com/nishigaya/entry/bash_completion_for_maven_2

it will complemet plugin parameters as well as well-known plugin
goals.
the above entry is written in japanse, sorry. But you can easily
find the link for the actual bash completion script.

Thanks,
Takashi Nishigaya

ccadete wrote:



Yes, it was that, now it is working :) thanks.

ccadete



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to