runWithOutput method
Runs this command with prepared configuration and output.
Subclasses should override this method.
Implementation
@override
Future<void> runWithOutput(
final Configuration<LogOption> commandConfig,
final CommandOutput output,
) async {
final projectId = commandConfig.value(LogOption.projectId);
final limit = commandConfig.value(LogOption.limit);
final inUtc = commandConfig.value(LogOption.utc);
var until = commandConfig.optionalValue(LogOption.until);
var since = commandConfig.optionalValue(LogOption.since);
final tailOpt = commandConfig.optionalValue(LogOption.tail);
final internalAllOpt = commandConfig.value(LogOption.all);
final raw = commandConfig.value(LogOption.raw);
final anyTimeSpanIsSet = until != null || since != null;
if (internalAllOpt) {
if (anyTimeSpanIsSet) {
logger.warning(
'The --all option cannot be combined with --until or --since.',
);
until = null;
since = null;
}
} else if (tailOpt == true) {
if (anyTimeSpanIsSet) {
throw CloudCliUsageException(
'The --tail option cannot be combined with --since or --until.',
);
}
} else if (until != null && since != null && until.isBefore(since)) {
throw CloudCliUsageException(
'The --until value must be after --since value.',
);
}
final client = runner.serviceProvider.cloudApiClient;
if (tailOpt == true) {
await renderCommand(
output,
operation: () async => LogsOperations.tailContainerLog(
client,
projectId: projectId,
limit: limit,
),
textOutputUi: LogTailTextUi(utc: inUtc, raw: raw, limit: limit),
);
return;
}
await renderCommand(
output,
operation: () => LogsOperations.fetchContainerLog(
client,
projectId: projectId,
before: until,
after: since,
limit: limit,
),
textOutputUi: LogListTextUi(utc: inUtc, raw: raw),
);
}