pub fn classify(
output: &CommandOutput,
command: &str,
patterns: &[Pattern],
) -> ClassificationExpand description
Classify command output using patterns and automatic category detection.
This is the main entry point for output classification. It analyzes the command’s exit code, output size, and applies pattern matching to determine the appropriate presentation strategy.
§Algorithm
- Failure path (exit_code ≠ 0): Apply failure pattern or smart truncation
- Small success (output ≤ 4KB): Pass through verbatim
- Pattern match: Extract summary using success pattern
- Category fallback: Use command category to determine behavior
§Arguments
output- The command’s exit code, stdout, and stderrcommand- The command string (used for pattern matching and category detection)patterns- List of patterns to try (typicallypattern::builtins+ user patterns)
§Returns
A Classification indicating how to present the output.
§Examples
use double_o::{classify, CommandOutput};
use double_o::pattern::builtins;
let output = CommandOutput {
stdout: b"test result: ok. 5 passed; 0 failed; finished in 0.3s".to_vec(),
stderr: Vec::new(),
exit_code: 0,
};
let patterns = builtins();
let result = classify(&output, "cargo test", patterns);