pub fn active_task(root: &Path) -> Option<(String, Vec<String>)>Expand description
The active task of the checkout at root: its id and scope, while its outcome is active.
use majordomus_cli::guard::active_task;
let dir = tempfile::tempdir().unwrap();
assert_eq!(active_task(dir.path()), None, "no task record");
let state = dir.path().join(".ai/local/state");
std::fs::create_dir_all(&state).unwrap();
let record = "id: t-1\noutcome: active\nscope:\n - lib\n";
std::fs::write(state.join("current.yaml"), record).unwrap();
assert_eq!(active_task(dir.path()), Some(("t-1".to_string(), vec!["lib".to_string()])));
let finished = record.replace("active", "completed");
std::fs::write(state.join("current.yaml"), finished).unwrap();
assert_eq!(active_task(dir.path()), None, "a finished task claims nothing");