Executor constructor
Executor(})
Implementation
new(
this.name,
this.shortDescription,
String version,
List<Command> commands, {
this.longDescription,
List<AccessorListOption>? accessors,
List<Flag<Object?>>? flags,
List<Option<Object?>>? options,
List<String>? defaultCommandPath,
this.context,
this.helpFormatter,
}) : _version = _validateVersion(version),
commands = List.unmodifiable(commands),
accessors = List.unmodifiable(accessors ?? const []),
flags = List.unmodifiable(flags ?? const []),
options = List.unmodifiable(options ?? const []),
defaultCommandPath = defaultCommandPath == null
? null
: List.unmodifiable(defaultCommandPath) {
final placements = HashSet<Command>.identity();
void visit(Iterable<Command> children) {
for (final command in children) {
if (!placements.add(command)) {
throw MambaRegistryError(
'Command instance ${command.name} occupies more than one path.',
);
}
if (_owners[command] != null) {
throw MambaRegistryError(
'Command instance ${command.name} already belongs to a configured Executor.',
);
}
if (command is GroupCommand) visit(command.commands);
}
}
visit(this.commands);
// Validate everything before claiming any identity or binding metadata.
_execution = _Execution(this);
for (final command in placements) {
_owners[command] = this;
}
_execution.bindMetadata();
}