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 results = argResults!;
final rest = results.rest;
if (rest.length > 1) {
stderr.writeln('status takes at most one positional argument.');
return 64;
}
final root = rest.isEmpty ? Directory.current.path : rest.first;
final DialectProject project;
try {
project = DialectProject.load(root);
} on FileSystemException catch (e) {
stderr.writeln(e.message);
stderr.writeln(
'Run `dialect init` first, or pass the project root as an argument.',
);
return 66;
} on FormatException catch (e) {
stderr.writeln('dialect.yaml or an ARB file is malformed:');
stderr.writeln(' ${e.message}');
return 65;
}
if (project.config.targetLocales.isEmpty) {
stdout.writeln(
'! dialect status: no `target_locales` configured in dialect.yaml.',
);
stdout.writeln(' Add a target locale and re-run.');
return 0;
}
final summary = computeStatus(project);
stdout.writeln(renderTable(_tableRows(summary)));
return 0;
}