Skip to main content

analyze

Function analyze 

Source
pub fn analyze(command: &str) -> Option<Steer>
Expand description

Classify a shell command or multi-line scriptlet. None means “allow” — no ct tool clearly serves it. A single command runs the high-confidence idiom matcher ([analyze_one]); a multi-line scriptlet is classified line by line ([analyze_script]) so a hand-sequenced series of ct-serviceable steps is steered toward one shell-less ct and chain. Never re-steers a command that already invokes ct.

use coding_tools::steer::analyze;
let s = analyze("find . -name '*.rs' | xargs grep TODO").unwrap();
assert_eq!(s.tool, "ct search");
assert!(analyze("cargo build && cargo test").is_none());
assert!(analyze("ct search --grep TODO").is_none());

A multi-line scriptlet whose every meaningful step is ct or ct-advisable (and not all are ct yet) folds into a single ct and A ::: B chain; see the folds_all_ct_or_advisable_scriptlet_into_one_chain test.