chimera icon indicating copy to clipboard operation
chimera copied to clipboard

[Enhancement] Support repeating command sequences

Open Pante opened this issue 4 years ago • 0 comments

Is your feature request related to a problem? Please describe. At present, adding a repeating sequence of command is more painful than necessary as it is not supported directly by Chimera. Developers wishing to add a repeating sequence need to manually iterate over each sequence and append it to the leaf of the previous sequence.

For example:

var builder = Argument.of("borderSize", IntegerArgumentType.integer(1)).then(Argument.of("borderShrinkTime", LongArgumentType.longArg(1)));
var command = builder.build();
var root = command;

for (var i = 0; i < 10; i++) {
  var child = builder.build();
  command.addChild(child);
  command = child;
}

This is both unwieldy since it needs to be manually re-coded for each repeating sequences and error-prone since iteratively adding sequences requires juggling multiple conditions and variables.

Describe the solution you'd like We propose adding a repeating(int times) method to Literal and Argument, and their respective builders to facilitate adding repeating sequences.

Additional context This issue was first raised by MrLn on Discord.

Pante avatar Aug 03 '21 14:08 Pante