runWithConfig method

  1. @override
Future<void> runWithConfig(
  1. Configuration<O> commandConfig
)

Runs this command with prepared configuration (options).

Refuses an interactiveOnly command in --non-interactive mode, requires the login if requireLogin is set, then creates a CommandOutput from the global --format option and delegates to runWithOutput. Subclasses should override runWithOutput.

Throws CloudCliUsageException if the command is interactiveOnly and --non-interactive is set.

Implementation

@override
Future<void> runWithConfig(Configuration<O> commandConfig) async {
  if (interactiveOnly && globalConfiguration.nonInteractive) {
    throw CloudCliUsageException(
      'The $name command is interactive and cannot run with --non-interactive.',
      hint: nonInteractiveHint,
    );
  }

  await _requireLogin();

  final output = CommandOutput(
    format: globalConfiguration.format,
    logger: logger,
  );
  await runWithOutput(commandConfig, output);
}