status method
Present first, running second.
The order matters: a stopped daemon and an uninstalled one both fail the running probe, and calling the second one "stopped" would send an operator to a start button for software that is not there.
Implementation
@override
Future<FormulaStatusReport> status(FormulaContext context) async {
final present = await validate(context);
if (!present.valid) {
return FormulaStatusReport(
formula: spec.id,
status: FormulaStatus.absent,
message: present.message,
checkedAt: context.now(),
);
}
final step = statusStepFor(context.platform.osName);
if (step == null) {
return FormulaStatusReport(
formula: spec.id,
status: FormulaStatus.installed,
version: present.detectedVersion,
message: present.message,
checkedAt: context.now(),
);
}
final probe = await executor.run(step.executable, step.args);
final detail = (probe.ok ? probe.stdout : probe.stderr).trim();
return FormulaStatusReport(
formula: spec.id,
status: statusFrom(probe),
version: present.detectedVersion,
// One line: this is a badge's tooltip, not a log. The log is what
// `verify` is for.
message: detail.isEmpty ? present.message : detail.split('\n').first,
checkedAt: context.now(),
);
}