serve function

Future<void> serve(
  1. List<String> args,
  2. FunctionTarget? nameToFunctionTarget(
    1. String
    )
)

If there is an invalid configuration, exitCode will be set to a non-zero value and the returned Future will completes quickly.

If there are no configuration errors, the returned Future will not complete until the process has received signal ProcessSignal.sigterm or ProcessSignal.sigint.

Implementation

Future<void> serve(
  List<String> args,
  FunctionTarget? Function(String) nameToFunctionTarget,
) async {
  try {
    await _serve(args, nameToFunctionTarget);
  } on BadConfigurationException catch (e) {
    stderr.writeln(red.wrap(e.message));
    if (e.details != null) {
      stderr.writeln(e.details);
    }
    exitCode = ExitCode.usage.code;
  }
}