runWithOutput method
Runs this command with prepared configuration and output.
Subclasses should override this method.
Implementation
@override
Future<void> runWithOutput(
final Configuration<TopOption> commandConfig,
final CommandOutput output,
) async {
final String projectId = commandConfig.value(TopOption.projectId);
final bool inUtc = commandConfig.value(TopOption.utc);
final Duration interval = commandConfig.value(TopOption.interval);
final Client client = runner.serviceProvider.cloudApiClient;
if (!logger.inlineTerminal.hasTerminal) {
throw FailureException(
error: 'The top command needs an interactive terminal.',
hint: nonInteractiveHint,
);
}
late final TopSnapshot initial;
await logger.progress('Loading $projectId', () async {
initial = await TopOperations.fetchSnapshot(
client,
projectId: projectId,
deploymentLimit: _deploymentLimit,
logLimit: _logLimit,
);
return true;
});
await runTopTui(
baseCommand: baseCommand,
projectId: projectId,
initial: initial,
snapshots: TopOperations.watchSnapshots(
client,
initial: initial,
projectId: projectId,
interval: interval,
metricsInterval: _metricsInterval,
deploymentLimit: _deploymentLimit,
logLimit: _logLimit,
),
utc: inUtc,
interval: interval,
);
}