CmdLineParser: Require plugin option names to start with '-'
This is normally a requirement for args4j options, but in the case of plugin options, the option name is produced by prefixing with "--myplugin", so an incorrect name in the @Option annotation in a plugin will not produce an error. Add a manual check for this case, forcing options to always be named "--myplugin-o" or "--myplugin--opt". Change-Id: I9e6810ec5470f001b8e772f046e4d3e8be5f7247
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
|
||||
package com.google.gerrit.util.cli;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.gerrit.util.cli.Localizable.localizable;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
@@ -426,6 +427,7 @@ public class CmdLineParser {
|
||||
|
||||
PrefixedOption(String prefix, Option o) {
|
||||
this.prefix = prefix;
|
||||
checkArgument(o.name().startsWith("-"), "Option name must start with '-': %s", o);
|
||||
this.o = o;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user