// Provenance: own design — shared run scripts (spec §7.1)
namespace Godosa.Core.Runs.Scripts;
/// Auto-output filter: a line of level prints when level ≤ max(current, floor);
/// = log lines and failures.
public sealed class RunOutput(Action write, OutputLevel floor)
{
public void Emit(OutputLevel level, OutputLevel current, string line)
{
if (level <= (current > floor ? current : floor))
write(line);
}
public void Always(string line) => write(line);
public static OutputLevel Parse(string name) => name switch
{
"quiet" => OutputLevel.Quiet, "checkpoints" => OutputLevel.Checkpoints, "labels" => OutputLevel.Labels,
"steps" => OutputLevel.Steps, "trace" => OutputLevel.Trace, _ => throw new ScriptFault($"bad output level '{name}'"),
};
}