Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documentation bug, the documented example leads to: io.vertx.core.cli.MissingValueException: The option 'help' requires a value #23

Open
cinterloper opened this issue Apr 23, 2016 · 5 comments
Labels

Comments

@cinterloper
Copy link

cinterloper commented Apr 23, 2016

when i use

addOption(new Option()
                    .setArgName("help")
                    .setShortName("h")
                    .setLongName("help"));

and type a command like

% shadowone -h

i get

io.vertx.core.cli.MissingValueException: The option 'help' requires a value
        at io.vertx.core.cli.impl.DefaultParser.checkRequiredValues(DefaultParser.java:201)
        at io.vertx.core.cli.impl.DefaultParser.parse(DefaultParser.java:125)
        at io.vertx.core.cli.impl.DefaultParser.parse(DefaultParser.java:82)
        at io.vertx.core.cli.impl.DefaultCLI.parse(DefaultCLI.java:47)
        at io.vertx.core.cli.CLI$parse$3.call(Unknown Source)
        at net.iowntheinter.cintershell.impl.cmds.example.TestOneShot$__clinit__closure1.doCall(TestOneShot.groovy:43)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
        at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1249)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1212)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
        at net.iowntheinter.cintershell.impl.commandOneShot.invokeMethod(commandOneShot.groovy)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:430)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:369)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
        at net.iowntheinter.cintershell.impl.commandOneShot$_closure1.doCall(commandOneShot.groovy:56)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
        at groovy.lang.Closure.call(Closure.java:426)
        at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:53)
        at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:105)
        at com.sun.proxy.$Proxy13.handle(Unknown Source)
        at io.vertx.ext.shell.command.impl.ProcessImpl.lambda$run$132(ProcessImpl.java:470)
        at io.vertx.core.impl.ContextImpl.lambda$wrapTask$18(ContextImpl.java:335)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
        at java.lang.Thread.run(Thread.java:745)

i believe it should work as described here:
http://vertx.io/docs/vertx-shell/java/#_command_arguments

@vietj
Copy link
Contributor

vietj commented Apr 23, 2016

can you rather report this to vertx-core repo to which it belongs ?

On Apr 23, 2016, at 4:24 AM, Grant Haywood notifications@github.com wrote:

when i use

addOption(new Option()
.setArgName("help")
.setShortName("h")
.setLongName("help"));
and type a command like

% shadowone -h
i get

io.vertx.core.cli.MissingValueException: The option 'help' requires a value
at io.vertx.core.cli.impl.DefaultParser.checkRequiredValues(DefaultParser.java:201)
at io.vertx.core.cli.impl.DefaultParser.parse(DefaultParser.java:125)
at io.vertx.core.cli.impl.DefaultParser.parse(DefaultParser.java:82)
at io.vertx.core.cli.impl.DefaultCLI.parse(DefaultCLI.java:47)
at io.vertx.core.cli.CLI$parse$3.call(Unknown Source)
at net.iowntheinter.cintershell.impl.cmds.example.TestOneShot$__clinit__closure1.doCall(TestOneShot.groovy:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1249)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1212)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
at net.iowntheinter.cintershell.impl.commandOneShot.invokeMethod(commandOneShot.groovy)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:430)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:369)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
at net.iowntheinter.cintershell.impl.commandOneShot$_closure1.doCall(commandOneShot.groovy:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
at groovy.lang.Closure.call(Closure.java:426)
at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:53)
at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:105)
at com.sun.proxy.$Proxy13.handle(Unknown Source)
at io.vertx.ext.shell.command.impl.ProcessImpl.lambda$run$132(ProcessImpl.java:470)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$18(ContextImpl.java:335)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at java.lang.Thread.run(Thread.java:745)

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub #23

@cescoffier
Copy link
Member

You need to call setFlag(true).

An option that does not receive a value is considered as a flag.

@cescoffier
Copy link
Member

(however, as said by Julien, if this does not work, people open a bug on vertx-core).

@cinterloper
Copy link
Author

cinterloper commented Apr 23, 2016

Well,
This IS a documentation bug on vertx-shell, its not a bug in vertx core.

http://vertx.io/docs/vertx-shell/java/#_command_arguments

gives an example

When an option named help is added to the CLI object, the shell will take care of generating the command usage when the option is activated:

CLI cli = CLI.create("my-command").
    addArgument(new Argument().setArgName("my-arg")).
    addOption(new Option().setArgName("help").setShortName("h").setLongName("help"));
CommandBuilder command = CommandBuilder.command(cli);
command.processHandler(process -> {
  // ...
});

which does not include the setFlag(true) statement

this is the example which I am reporting as incomplete/incorrect, as it produces an error when i follow it

novice users may find it very discouraging if there are examples in the documentation which are incomplete/misleading

@cinterloper cinterloper changed the title io.vertx.core.cli.MissingValueException: The option 'help' requires a value documentation bug, the documented example leads to: io.vertx.core.cli.MissingValueException: The option 'help' requires a value Apr 23, 2016
@cescoffier cescoffier reopened this Apr 23, 2016
@cescoffier
Copy link
Member

Oh I see, thanks for the details ! As you said definitely a mistake in the doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants