Skip to content

Commit fcec60d

Browse files
committed
Allow -E in MultiCommand tools
1 parent 3f7d287 commit fcec60d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

libs/cli/src/main/java/org/elasticsearch/cli/MultiCommand.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public class MultiCommand extends Command {
4545
*/
4646
public MultiCommand(final String description, final Runnable beforeMain) {
4747
super(description, beforeMain);
48+
// Accepting -E here does not prevent subcommands receiving -E arguments, since we also set `posixlyCorrect` below.
49+
// This stops option parsing when the first non-option is encountered.
50+
parser.accepts("E", "Unused. Pass to a subcommand instead").withRequiredArg();
4851
parser.posixlyCorrect(true);
4952
}
5053

x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalTool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static void main(String[] args) throws Exception {
4646
.withRequiredArg().ofType(Integer.class).defaultsTo(10);
4747
this.arguments = parser.nonOptions("expression");
4848

49-
parser.accepts("E", "Unused. Only for compatibility with other CLI tools.").withRequiredArg().ofType(KeyValuePair.class);
49+
parser.accepts("E", "Unused. Only for compatibility with other CLI tools.").withRequiredArg();
5050
}
5151

5252
@Override

0 commit comments

Comments
 (0)