vertx-shell icon indicating copy to clipboard operation
vertx-shell copied to clipboard

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

Open cinterloper opened this issue 8 years ago • 5 comments

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

cinterloper avatar Apr 23 '16 02:04 cinterloper

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

On Apr 23, 2016, at 4:24 AM, Grant Haywood [email protected] 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 https://github.com/vert-x3/vertx-shell/issues/23

vietj avatar Apr 23 '16 10:04 vietj

You need to call setFlag(true).

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

cescoffier avatar Apr 23 '16 11:04 cescoffier

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

cescoffier avatar Apr 23 '16 11:04 cescoffier

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 avatar Apr 23 '16 15:04 cinterloper

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

cescoffier avatar Apr 23 '16 16:04 cescoffier