run method

  1. @override
void run()
override

Runs this command.

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

Implementation

@override
void run() {
  final debug = argResults!['debug'] as bool;

  Settings().setVerbose(enabled: debug);
  Environment().certbotVerbose = debug;

  final config = ConfigYaml()..validate(() => showUsage(argParser));

  if (Strings.isEmpty(config.containerid)) {
    printerr('The config.containerid is empty');
    return;
  }

  final containerid = config.containerid!;

  final container = Containers().findByContainerId(containerid);
  if (container == null) {
    printerr("Can't find container with id: $containerid");
    return;
  }

  if (container.isRunning) {
    var cmd = 'docker exec -it $containerid /home/bin/acquire ';

    print('');
    print(orange(
        'Please be patient this can take a quite a few minutes to complete'));

    if (debug == true) {
      cmd += ' --debug';
    }
    cmd.run;
  } else {
    printerr(red("The Nginx-LE container $containerid isn't running. "
        "Use 'nginx-le start' to start the container"));
  }
}