exitCodeFor function
The exit code for a whole run: 0 when every input converted, otherwise the code of the most serious outcome — a failure (1) before a missing tool (3) before a refusal to overwrite (4).
Implementation
int exitCodeFor(Iterable<ConvertOutcome> outcomes) {
const severity = <ConvertOutcome>[
ConvertOutcome.failed,
ConvertOutcome.missingTool,
ConvertOutcome.wouldOverwrite,
];
for (final outcome in severity) {
if (outcomes.contains(outcome)) return outcome.exitCode;
}
return 0;
}