CLIBuilder question/problem

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

CLIBuilder question/problem

Warner Onstine-3
Hi all,
I'm having an issue with CLIBuilder, with this code:
static void main(args) {
                def chamaHome = System.getenv("CHAMA_HOME")
                if(!chamaHome) {
                    println "Environment variable CHAMA_HOME not set. Please set it
to the location of your Chama installation and try again."
                    System.exit(0)
                }

                Chama chama = new Chama()
                chama.executeParams(args)
  }
       
        void executeParams(args) {
            def cli = new CliBuilder(usage : "groovy org.chama.Chama [option]
[action] [arguments]*",
                        writer: new PrintWriter(System.out))
               
                cli.p(argName: 'projectName', args:1, longOpt: 'project')
                cli.h(longOpt: 'help', 'Print this message')
                cli.g(argName: 'groupName', args: 1)
                cli.d(argName: 'defaultPackage', args:1)
                cli.c(argName: 'all', argName:'')
                def options = cli.parse(args)
               
                if(options.p) {
                Project project = new Project()
                project.name = options.p
                out.println("project name is " + options.p)

                }
        }

When I try and execute it I get this ArrayIndexOutOfBoundsException:1
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(DefaultGroovyMethods.java:1985)
        at gjdk.java.lang.Object_GroovyReflectorArray.invoke(Unknown Source)
        at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
        at org.codehaus.groovy.runtime.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:109)
        at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:713)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
        at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:119)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
        at groovy.util.CliBuilder.invokeMethod(CliBuilder.groovy:37)
        at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:136)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
        at org.chama.Chama.executeParams(Chama.groovy:45)
        at gjdk.org.chama.Chama_GroovyReflector.invoke(Unknown Source)
        at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
        at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:713)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
        at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:131)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
        at org.chama.Chama.main(Chama.groovy:38)

The line 45 that it is referring to is this one (I think):
cli.p(argName: 'projectName', args:1, longOpt: 'project')

Thanks in advance for the help!

-warner

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

RE: CLIBuilder question/problem

Dierk König
Hi,
could you please try to submit the smallest example
that doesn't work for you?

Dierk

> -----Original Message-----
> From: Warner Onstine [mailto:[hidden email]]
> Sent: Mittwoch, 17. Januar 2007 5:04
> To: [hidden email]
> Subject: [groovy-user] CLIBuilder question/problem
>
>
> Hi all,
> I'm having an issue with CLIBuilder, with this code:
> static void main(args) {
> def chamaHome = System.getenv("CHAMA_HOME")
> if(!chamaHome) {
>    println "Environment variable CHAMA_HOME not
> set. Please set it
> to the location of your Chama installation and try again."
>    System.exit(0)
> }
>
> Chama chama = new Chama()
> chama.executeParams(args)
>   }
>
> void executeParams(args) {
>    def cli = new CliBuilder(usage : "groovy
> org.chama.Chama [option]
> [action] [arguments]*",
>        writer: new PrintWriter(System.out))
>
> cli.p(argName: 'projectName', args:1, longOpt: 'project')
> cli.h(longOpt: 'help', 'Print this message')
> cli.g(argName: 'groupName', args: 1)
> cli.d(argName: 'defaultPackage', args:1)
> cli.c(argName: 'all', argName:'')
> def options = cli.parse(args)
>
> if(options.p) {
>        Project project = new Project()
>        project.name = options.p
>        out.println("project name is " + options.p)
>
> }
> }
>
> When I try and execute it I get this ArrayIndexOutOfBoundsException:1
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
>         at
> org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(DefaultGroo
> vyMethods.java:1985)
>         at
> gjdk.java.lang.Object_GroovyReflectorArray.invoke(Unknown Source)
>         at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
>         at
> org.codehaus.groovy.runtime.NewInstanceMetaMethod.invoke(NewInstan
> ceMetaMethod.java:109)
>         at
> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaCla
> ssHelper.java:713)
>         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
>         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
>         at
> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:119)
>         at
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> er.java:111)
>         at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> riptBytecodeAdapter.java:187)
>         at groovy.util.CliBuilder.invokeMethod(CliBuilder.groovy:37)
>         at
> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:136)
>         at
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> er.java:111)
>         at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> riptBytecodeAdapter.java:187)
>         at org.chama.Chama.executeParams(Chama.groovy:45)
>         at gjdk.org.chama.Chama_GroovyReflector.invoke(Unknown Source)
>         at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
>         at
> org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaCla
> ssHelper.java:713)
>         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
>         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
>         at
> org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:131)
>         at
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> er.java:111)
>         at
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> riptBytecodeAdapter.java:187)
>         at org.chama.Chama.main(Chama.groovy:38)
>
> The line 45 that it is referring to is this one (I think):
> cli.p(argName: 'projectName', args:1, longOpt: 'project')
>
> Thanks in advance for the help!
>
> -warner
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: CLIBuilder question/problem

Warner Onstine-3
So, I commented out every other option except the first one:
cli.p(argName: 'projectName', args:1, longOpt: 'project')

and I am still getting the error message:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1

-warner

On 1/17/07, Dierk Koenig <[hidden email]> wrote:

> Hi,
> could you please try to submit the smallest example
> that doesn't work for you?
>
> Dierk
>
> > -----Original Message-----
> > From: Warner Onstine [mailto:[hidden email]]
> > Sent: Mittwoch, 17. Januar 2007 5:04
> > To: [hidden email]
> > Subject: [groovy-user] CLIBuilder question/problem
> >
> >
> > Hi all,
> > I'm having an issue with CLIBuilder, with this code:
> > static void main(args) {
> >               def chamaHome = System.getenv("CHAMA_HOME")
> >               if(!chamaHome) {
> >                   println "Environment variable CHAMA_HOME not
> > set. Please set it
> > to the location of your Chama installation and try again."
> >                   System.exit(0)
> >               }
> >
> >               Chama chama = new Chama()
> >               chama.executeParams(args)
> >       }
> >
> >       void executeParams(args) {
> >           def cli = new CliBuilder(usage : "groovy
> > org.chama.Chama [option]
> > [action] [arguments]*",
> >                       writer: new PrintWriter(System.out))
> >
> >               cli.p(argName: 'projectName', args:1, longOpt: 'project')
> >               cli.h(longOpt: 'help', 'Print this message')
> >               cli.g(argName: 'groupName', args: 1)
> >               cli.d(argName: 'defaultPackage', args:1)
> >               cli.c(argName: 'all', argName:'')
> >               def options = cli.parse(args)
> >
> >               if(options.p) {
> >               Project project = new Project()
> >               project.name = options.p
> >               out.println("project name is " + options.p)
> >
> >               }
> >       }
> >
> > When I try and execute it I get this ArrayIndexOutOfBoundsException:1
> > Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
> >         at
> > org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(DefaultGroo
> > vyMethods.java:1985)
> >         at
> > gjdk.java.lang.Object_GroovyReflectorArray.invoke(Unknown Source)
> >         at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
> >         at
> > org.codehaus.groovy.runtime.NewInstanceMetaMethod.invoke(NewInstan
> > ceMetaMethod.java:109)
> >         at
> > org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaCla
> > ssHelper.java:713)
> >         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
> >         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
> >         at
> > org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:119)
> >         at
> > org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> > er.java:111)
> >         at
> > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> > riptBytecodeAdapter.java:187)
> >         at groovy.util.CliBuilder.invokeMethod(CliBuilder.groovy:37)
> >         at
> > org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:136)
> >         at
> > org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> > er.java:111)
> >         at
> > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> > riptBytecodeAdapter.java:187)
> >         at org.chama.Chama.executeParams(Chama.groovy:45)
> >         at gjdk.org.chama.Chama_GroovyReflector.invoke(Unknown Source)
> >         at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
> >         at
> > org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaCla
> > ssHelper.java:713)
> >         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
> >         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
> >         at
> > org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:131)
> >         at
> > org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> > er.java:111)
> >         at
> > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> > riptBytecodeAdapter.java:187)
> >         at org.chama.Chama.main(Chama.groovy:38)
> >
> > The line 45 that it is referring to is this one (I think):
> > cli.p(argName: 'projectName', args:1, longOpt: 'project')
> >
> > Thanks in advance for the help!
> >
> > -warner
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: CLIBuilder question/problem

Warner Onstine-3
Figured it out after staring at CLIBuilderTest some more, I was
missing the description of the option at the end (for some reason I
thought it wasn't necessary).

cli.p(argName: 'projectName', args:1, longOpt: 'project', 'Create New Project')

-warner

On 1/17/07, Warner Onstine <[hidden email]> wrote:

> So, I commented out every other option except the first one:
> cli.p(argName: 'projectName', args:1, longOpt: 'project')
>
> and I am still getting the error message:
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
>
> -warner
>
> On 1/17/07, Dierk Koenig <[hidden email]> wrote:
> > Hi,
> > could you please try to submit the smallest example
> > that doesn't work for you?
> >
> > Dierk
> >
> > > -----Original Message-----
> > > From: Warner Onstine [mailto:[hidden email]]
> > > Sent: Mittwoch, 17. Januar 2007 5:04
> > > To: [hidden email]
> > > Subject: [groovy-user] CLIBuilder question/problem
> > >
> > >
> > > Hi all,
> > > I'm having an issue with CLIBuilder, with this code:
> > > static void main(args) {
> > >               def chamaHome = System.getenv("CHAMA_HOME")
> > >               if(!chamaHome) {
> > >                   println "Environment variable CHAMA_HOME not
> > > set. Please set it
> > > to the location of your Chama installation and try again."
> > >                   System.exit(0)
> > >               }
> > >
> > >               Chama chama = new Chama()
> > >               chama.executeParams(args)
> > >       }
> > >
> > >       void executeParams(args) {
> > >           def cli = new CliBuilder(usage : "groovy
> > > org.chama.Chama [option]
> > > [action] [arguments]*",
> > >                       writer: new PrintWriter(System.out))
> > >
> > >               cli.p(argName: 'projectName', args:1, longOpt: 'project')
> > >               cli.h(longOpt: 'help', 'Print this message')
> > >               cli.g(argName: 'groupName', args: 1)
> > >               cli.d(argName: 'defaultPackage', args:1)
> > >               cli.c(argName: 'all', argName:'')
> > >               def options = cli.parse(args)
> > >
> > >               if(options.p) {
> > >               Project project = new Project()
> > >               project.name = options.p
> > >               out.println("project name is " + options.p)
> > >
> > >               }
> > >       }
> > >
> > > When I try and execute it I get this ArrayIndexOutOfBoundsException:1
> > > Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
> > >         at
> > > org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(DefaultGroo
> > > vyMethods.java:1985)
> > >         at
> > > gjdk.java.lang.Object_GroovyReflectorArray.invoke(Unknown Source)
> > >         at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
> > >         at
> > > org.codehaus.groovy.runtime.NewInstanceMetaMethod.invoke(NewInstan
> > > ceMetaMethod.java:109)
> > >         at
> > > org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaCla
> > > ssHelper.java:713)
> > >         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
> > >         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
> > >         at
> > > org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:119)
> > >         at
> > > org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> > > er.java:111)
> > >         at
> > > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> > > riptBytecodeAdapter.java:187)
> > >         at groovy.util.CliBuilder.invokeMethod(CliBuilder.groovy:37)
> > >         at
> > > org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:136)
> > >         at
> > > org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> > > er.java:111)
> > >         at
> > > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> > > riptBytecodeAdapter.java:187)
> > >         at org.chama.Chama.executeParams(Chama.groovy:45)
> > >         at gjdk.org.chama.Chama_GroovyReflector.invoke(Unknown Source)
> > >         at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
> > >         at
> > > org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaCla
> > > ssHelper.java:713)
> > >         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
> > >         at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
> > >         at
> > > org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:131)
> > >         at
> > > org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> > > er.java:111)
> > >         at
> > > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> > > riptBytecodeAdapter.java:187)
> > >         at org.chama.Chama.main(Chama.groovy:38)
> > >
> > > The line 45 that it is referring to is this one (I think):
> > > cli.p(argName: 'projectName', args:1, longOpt: 'project')
> > >
> > > Thanks in advance for the help!
> > >
> > > -warner
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe from this list please visit:
> > >
> > >     http://xircles.codehaus.org/manage_email
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
>

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

RE: CLIBuilder question/problem

Dierk König
In reply to this post by Warner Onstine-3
ok. This is a known issue with commons-cli that CliBuilder bases upon.
It comes from longOpt being a substring of argName.
I remember there was a JIRA issue about it. If not, please open one.

We have to check whether the issue was solved in a newer version
of commons-cli and consider upgrading.

Dierk

> -----Original Message-----
> From: Warner Onstine [mailto:[hidden email]]
> Sent: Mittwoch, 17. Januar 2007 14:35
> To: [hidden email]
> Subject: Re: [groovy-user] CLIBuilder question/problem
>
>
> So, I commented out every other option except the first one:
> cli.p(argName: 'projectName', args:1, longOpt: 'project')
>
> and I am still getting the error message:
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
>
> -warner
>
> On 1/17/07, Dierk Koenig <[hidden email]> wrote:
> > Hi,
> > could you please try to submit the smallest example
> > that doesn't work for you?
> >
> > Dierk
> >
> > > -----Original Message-----
> > > From: Warner Onstine [mailto:[hidden email]]
> > > Sent: Mittwoch, 17. Januar 2007 5:04
> > > To: [hidden email]
> > > Subject: [groovy-user] CLIBuilder question/problem
> > >
> > >
> > > Hi all,
> > > I'm having an issue with CLIBuilder, with this code:
> > > static void main(args) {
> > >               def chamaHome = System.getenv("CHAMA_HOME")
> > >               if(!chamaHome) {
> > >                   println "Environment variable CHAMA_HOME not
> > > set. Please set it
> > > to the location of your Chama installation and try again."
> > >                   System.exit(0)
> > >               }
> > >
> > >               Chama chama = new Chama()
> > >               chama.executeParams(args)
> > >       }
> > >
> > >       void executeParams(args) {
> > >           def cli = new CliBuilder(usage : "groovy
> > > org.chama.Chama [option]
> > > [action] [arguments]*",
> > >                       writer: new PrintWriter(System.out))
> > >
> > >               cli.p(argName: 'projectName', args:1, longOpt:
> 'project')
> > >               cli.h(longOpt: 'help', 'Print this message')
> > >               cli.g(argName: 'groupName', args: 1)
> > >               cli.d(argName: 'defaultPackage', args:1)
> > >               cli.c(argName: 'all', argName:'')
> > >               def options = cli.parse(args)
> > >
> > >               if(options.p) {
> > >               Project project = new Project()
> > >               project.name = options.p
> > >               out.println("project name is " + options.p)
> > >
> > >               }
> > >       }
> > >
> > > When I try and execute it I get this ArrayIndexOutOfBoundsException:1
> > > Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
> > >         at
> > > org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(DefaultGroo
> > > vyMethods.java:1985)
> > >         at
> > > gjdk.java.lang.Object_GroovyReflectorArray.invoke(Unknown Source)
> > >         at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
> > >         at
> > > org.codehaus.groovy.runtime.NewInstanceMetaMethod.invoke(NewInstan
> > > ceMetaMethod.java:109)
> > >         at
> > > org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaCla
> > > ssHelper.java:713)
> > >         at
> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
> > >         at
> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
> > >         at
> > > org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:119)
> > >         at
> > > org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> > > er.java:111)
> > >         at
> > > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> > > riptBytecodeAdapter.java:187)
> > >         at groovy.util.CliBuilder.invokeMethod(CliBuilder.groovy:37)
> > >         at
> > > org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:136)
> > >         at
> > > org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> > > er.java:111)
> > >         at
> > > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> > > riptBytecodeAdapter.java:187)
> > >         at org.chama.Chama.executeParams(Chama.groovy:45)
> > >         at gjdk.org.chama.Chama_GroovyReflector.invoke(Unknown Source)
> > >         at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
> > >         at
> > > org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaCla
> > > ssHelper.java:713)
> > >         at
> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
> > >         at
> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
> > >         at
> > > org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:131)
> > >         at
> > > org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> > > er.java:111)
> > >         at
> > > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> > > riptBytecodeAdapter.java:187)
> > >         at org.chama.Chama.main(Chama.groovy:38)
> > >
> > > The line 45 that it is referring to is this one (I think):
> > > cli.p(argName: 'projectName', args:1, longOpt: 'project')
> > >
> > > Thanks in advance for the help!
> > >
> > > -warner
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe from this list please visit:
> > >
> > >     http://xircles.codehaus.org/manage_email
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> >     http://xircles.codehaus.org/manage_email
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

RE: CLIBuilder question/problem

Dierk König
In reply to this post by Warner Onstine-3
ok, if it works fine, ignore my other mail :-)

Dierk

> -----Original Message-----
> From: Warner Onstine [mailto:[hidden email]]
> Sent: Mittwoch, 17. Januar 2007 15:18
> To: [hidden email]
> Subject: Re: [groovy-user] CLIBuilder question/problem
>
>
> Figured it out after staring at CLIBuilderTest some more, I was
> missing the description of the option at the end (for some reason I
> thought it wasn't necessary).
>
> cli.p(argName: 'projectName', args:1, longOpt: 'project', 'Create
> New Project')
>
> -warner
>
> On 1/17/07, Warner Onstine <[hidden email]> wrote:
> > So, I commented out every other option except the first one:
> > cli.p(argName: 'projectName', args:1, longOpt: 'project')
> >
> > and I am still getting the error message:
> > Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
> >
> > -warner
> >
> > On 1/17/07, Dierk Koenig <[hidden email]> wrote:
> > > Hi,
> > > could you please try to submit the smallest example
> > > that doesn't work for you?
> > >
> > > Dierk
> > >
> > > > -----Original Message-----
> > > > From: Warner Onstine [mailto:[hidden email]]
> > > > Sent: Mittwoch, 17. Januar 2007 5:04
> > > > To: [hidden email]
> > > > Subject: [groovy-user] CLIBuilder question/problem
> > > >
> > > >
> > > > Hi all,
> > > > I'm having an issue with CLIBuilder, with this code:
> > > > static void main(args) {
> > > >               def chamaHome = System.getenv("CHAMA_HOME")
> > > >               if(!chamaHome) {
> > > >                   println "Environment variable CHAMA_HOME not
> > > > set. Please set it
> > > > to the location of your Chama installation and try again."
> > > >                   System.exit(0)
> > > >               }
> > > >
> > > >               Chama chama = new Chama()
> > > >               chama.executeParams(args)
> > > >       }
> > > >
> > > >       void executeParams(args) {
> > > >           def cli = new CliBuilder(usage : "groovy
> > > > org.chama.Chama [option]
> > > > [action] [arguments]*",
> > > >                       writer: new PrintWriter(System.out))
> > > >
> > > >               cli.p(argName: 'projectName', args:1,
> longOpt: 'project')
> > > >               cli.h(longOpt: 'help', 'Print this message')
> > > >               cli.g(argName: 'groupName', args: 1)
> > > >               cli.d(argName: 'defaultPackage', args:1)
> > > >               cli.c(argName: 'all', argName:'')
> > > >               def options = cli.parse(args)
> > > >
> > > >               if(options.p) {
> > > >               Project project = new Project()
> > > >               project.name = options.p
> > > >               out.println("project name is " + options.p)
> > > >
> > > >               }
> > > >       }
> > > >
> > > > When I try and execute it I get this
> ArrayIndexOutOfBoundsException:1
> > > > Exception in thread "main"
> java.lang.ArrayIndexOutOfBoundsException: 1
> > > >         at
> > > > org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(DefaultGroo
> > > > vyMethods.java:1985)
> > > >         at
> > > > gjdk.java.lang.Object_GroovyReflectorArray.invoke(Unknown Source)
> > > >         at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
> > > >         at
> > > > org.codehaus.groovy.runtime.NewInstanceMetaMethod.invoke(NewInstan
> > > > ceMetaMethod.java:109)
> > > >         at
> > > > org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaCla
> > > > ssHelper.java:713)
> > > >         at
> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
> > > >         at
> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
> > > >         at
> > > > org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:119)
> > > >         at
> > > > org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> > > > er.java:111)
> > > >         at
> > > > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> > > > riptBytecodeAdapter.java:187)
> > > >         at groovy.util.CliBuilder.invokeMethod(CliBuilder.groovy:37)
> > > >         at
> > > > org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:136)
> > > >         at
> > > > org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> > > > er.java:111)
> > > >         at
> > > > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> > > > riptBytecodeAdapter.java:187)
> > > >         at org.chama.Chama.executeParams(Chama.groovy:45)
> > > >         at
> gjdk.org.chama.Chama_GroovyReflector.invoke(Unknown Source)
> > > >         at groovy.lang.MetaMethod.invoke(MetaMethod.java:115)
> > > >         at
> > > > org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaCla
> > > > ssHelper.java:713)
> > > >         at
> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
> > > >         at
> groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
> > > >         at
> > > > org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:131)
> > > >         at
> > > > org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelp
> > > > er.java:111)
> > > >         at
> > > > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Sc
> > > > riptBytecodeAdapter.java:187)
> > > >         at org.chama.Chama.main(Chama.groovy:38)
> > > >
> > > > The line 45 that it is referring to is this one (I think):
> > > > cli.p(argName: 'projectName', args:1, longOpt: 'project')
> > > >
> > > > Thanks in advance for the help!
> > > >
> > > > -warner
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe from this list please visit:
> > > >
> > > >     http://xircles.codehaus.org/manage_email
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe from this list please visit:
> > >
> > >     http://xircles.codehaus.org/manage_email
> > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email