doRun method
Implementation
@override
Future<int> doRun() async {
final args = argResults!;
final sourcePath = args[_argPath] as String?;
final fileForImport = args[_argFile] as String?;
final targetFileName = args[_argTarget] as String?;
final locale = args[_argLocale] as String?;
final importAll = args[_argAll] as bool;
final importNew = args[_argNew] as bool;
final importDiffs = args[_argDiffs] as bool?;
if (sourcePath == null) {
printUsage();
return success();
}
if (importAll) {
printVerbose('Import all translations from: $sourcePath.');
if (fileForImport != null) {
return error(1,
message:
"You can't use argument --$_argFile along with --$_argAll");
}
if (targetFileName != null) {
return error(1,
message:
"You can't use argument --$_argTarget along with --$_argAll");
}
} else {
printVerbose(
// ignore: prefer_interpolation_to_compose_strings
'Import ${fileForImport ?? 'main'} translations from: $sourcePath' +
(targetFileName != null ? ' to $targetFileName.' : '.'));
}
if (locale != null) {
printVerbose('Import only locale <$locale>');
}
final config = findConfigAndSetWorkingDir();
final l10nConfig = config.l10n;
final locales = locale != null
? [locale]
: (importNew ? null : await getLocales(l10nConfig));
return _importFromGooglePlay(
l10nConfig,
sourcePath,
fileForImport: fileForImport,
targetFileName: targetFileName,
importAll: importAll,
importDiffs: importDiffs,
locales: locales,
);
}