run method

  1. @override
Future<int> run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
Future<int> run() async {
  final key = argResults!['key'] as String;
  final id = argResults?['id'] as String? ?? '';
  final pId = await requireProjectIdAsync();

  final translation = Translation(
    projectId: pId,
    key: key,
  );
  if (id.isNotEmpty) {
    translation.id = id;
  }

  final client = container.read(translationServiceClientProvider);
  final result = await client.upsertTranslation(
    translation,
    options: getCallOptions(requireUser: false),
  );
  printOutput(result);
  return 0;
}