run method

  1. @override
Future<void> run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
Future<void> run() async {
  final args = argResults!;
  try {
    final certs = await CertGenerator.generate(
      outputDir: args['out'] as String,
      hosts: args['host'] as List<String>,
      force: args['force'] as bool,
    );
    stdout.writeln('Generated:');
    stdout.writeln('  CA cert:     ${certs.caCert}');
    stdout.writeln('  Server cert: ${certs.serverCert}');
    stdout.writeln('  Server key:  ${certs.serverKey}');
  } on CertGeneratorException catch (e) {
    throw CliError(e.message);
  }
}