CommandListOps extension

Extension methods for manipulating command lists.

Provides fluent operations for building derived tool definitions via ToolDefinition.copyWith.

final commands = baseTool.commands
    .without({'dcli', 'findproject'})
    .replacing('runner', myCustomRunner)
    .plus([newCommand]);
on

Methods

plus(List<CommandDefinition> additions) List<CommandDefinition>

Available on List<CommandDefinition>, provided by the CommandListOps extension

Return a new list with additions appended.
replacing(String name, CommandDefinition replacement) List<CommandDefinition>

Available on List<CommandDefinition>, provided by the CommandListOps extension

Return a new list with the named command replaced (keeps position).
without(Set<String> names) List<CommandDefinition>

Available on List<CommandDefinition>, provided by the CommandListOps extension

Return a new list with the named commands removed.