checkDomainsWithCLI function

void checkDomainsWithCLI(
  1. Iterable<String> input, {
  2. required Spinner spinner,
})

Implementation

void checkDomainsWithCLI(Iterable<String> input,
    {required Spinner spinner}) async {
  final checked = <CheckedDomain>[];

  await for (final domain in batchCheck(input)) {
    checked.add(domain);
    spinner.text = '${domain.toString().underline()} was checked...';
  }

  if (stdout.hasTerminal) {
    spinner.stop();

    final successes = checked.where((e) => e.available);
    stdout.writeln((successes.isNotEmpty
            ? '${successes.length} ${successes.length > 1 ? 'domains are' : 'domain is'} available'
            : 'All domains have been taken')
        .dim()
        .underline());
  }

  domainTable(checked);
}