run method
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 pId = await requireProjectIdAsync();
final client = container.read(configServiceClientProvider);
final result = await client.getCLIConfigForProject(
ProjectId(id: pId),
options: getCallOptions(),
);
final save = argResults?['save'] == true;
if (save) {
final path = argResults?['path'] as String? ?? '.';
final file = File('$path/localizable_project.json')
..writeAsStringSync(result.data);
if (isJsonOutput) {
printOutput({
'success': true,
'saved': true,
'path': file.path,
'data': result.data,
});
} else {
print('Saved project config to ${file.path}');
}
} else {
if (isJsonOutput) {
printOutput({'projectId': pId, 'config': result.data});
} else {
print(result.data);
}
}
return 0;
}