resolveClients static method

List<String> resolveClients(
  1. List<String> requested, {
  2. required bool allClients,
  3. required List<String> knownClients,
})

Resolves --client values (repeated or comma-separated) or --all-clients into a de-duplicated list, preserving order.

Implementation

static List<String> resolveClients(
  List<String> requested, {
  required bool allClients,
  required List<String> knownClients,
}) {
  final names = _unique(requested);
  if (allClients && names.isNotEmpty) {
    throw BuildException(
      'Use either --client or --all-clients, not both.',
      fix: 'Drop --all-clients to build only the named clients.',
    );
  }
  if (allClients) {
    if (knownClients.isEmpty) {
      throw BuildException(
        'No clients found in the clients/ directory.',
        fix: 'Run "udara_cli setup --clients <name>" to create one.',
      );
    }
    return List.of(knownClients);
  }
  if (names.isEmpty) {
    throw BuildException(
      'No client given.',
      fix: 'Pass --client <name> (repeat it or comma-separate for several), '
          'or --all-clients.',
    );
  }
  return names;
}