execute method

Future<int> execute(
  1. List<String> arguments
)

Runs arguments, returning the process exit code.

Every failure is translated into an exit code and a one-line message: 64 for a usage error, the exception's own code for a CliException, 1 otherwise. Nothing escapes as a stack trace, because a CLI that prints one for a mistyped flag is unusable.

Implementation

Future<int> execute(List<String> arguments) async {
  try {
    return await run(arguments) ?? 0;
  } on UsageException catch (e) {
    err.writeln(e);
    return 64;
  } on CliException catch (e) {
    err.writeln('error: ${e.message}');
    return e.exitCode;
  } on OmnyStoreException catch (e) {
    err.writeln('error: ${e.message}');
    return 1;
  } on FormatException catch (e) {
    err.writeln('error: ${e.message}');
    return 65;
  } finally {
    await _context?.close();
  }
}