runHotpatchCli function

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

Entry point for dart run flutter_hotpatch:hotpatch.

Implementation

Future<int> runHotpatchCli(List<String> arguments) async {
  final runner =
      CommandRunner<int>(
          'hotpatch',
          'Signed Dart code patches for Flutter apps on Android.\n\n'
              'Run commands from the app folder that holds hotpatch.yaml.',
        )
        ..addCommand(KeygenCommand())
        ..addCommand(ReleaseCommand())
        ..addCommand(PatchCommand())
        ..addCommand(PromoteCommand())
        ..addCommand(RollbackCommand())
        ..addCommand(StatusCommand());
  try {
    return await runner.run(arguments) ?? 0;
  } on UsageException catch (error) {
    stderr.writeln(error);
    return 64;
  } on CliException catch (error) {
    stderr.writeln('error: ${error.message}');
    return 1;
  } on HotpatchSecurityException catch (error) {
    stderr.writeln('error: ${error.message}');
    return 1;
  }
}