retrieve static method
SharedCommand
retrieve(
- CommandRegistry registry, {
- required String ownerApp,
- required String commandName,
- String? minVersion,
Retrieve a shared command from a CommandRegistry by name.
Returns the SharedCommand view of the registered command, or throws
UnknownCommandException if no command is registered under ownerApp
/ commandName. If minVersion is provided, throws
VersionMismatchException when the published version is below the
minimum.
Implementation
static SharedCommand retrieve(
CommandRegistry registry, {
required String ownerApp,
required String commandName,
String? minVersion,
}) {
final entry = registry.require(ownerApp, commandName);
if (minVersion != null && !_versionSatisfies(entry.version, minVersion)) {
throw VersionMismatchException(
commandName: commandName,
ownerApp: ownerApp,
requestedMinVersion: minVersion,
publishedVersion: entry.version,
);
}
return SharedCommand(command: entry.command, version: entry.version);
}