use std::fmt;
use std::path::PathBuf;
use crate::types::manifest::PackVersion;
use crate::types::name::ToolName;
use crate::types::report::Location;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Note {
Ignored {
root: PathBuf,
path: PathBuf,
},
UnusedNative {
dir: ToolName,
tool: ToolName,
},
SourceChanged {
location: Location,
},
}
impl fmt::Display for Note {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Ignored { root, path } => {
write!(
f,
"{}: ignored (dot entry)",
Location::file(root.join(path))
)
}
Self::UnusedNative { dir, tool } => write!(f, "native/{dir}: not for {tool}"),
Self::SourceChanged { location } => {
write!(f, "{location}: source changed, resolved again")
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AirslPin {
pub locked: Option<PackVersion>,
pub installed: PackVersion,
}
#[cfg(test)]
mod tests {
use super::*;
type TestResult = Result<(), Box<dyn std::error::Error>>;
#[test]
fn note_texts_match_the_spec() -> TestResult {
let ignored = Note::Ignored {
root: PathBuf::from("packs/core"),
path: PathBuf::from(".DS_Store"),
};
assert_eq!(
ignored.to_string(),
"packs/core/.DS_Store: ignored (dot entry)"
);
let native = Note::UnusedNative {
dir: ToolName::new("cluade")?,
tool: ToolName::new("claude")?,
};
assert_eq!(native.to_string(), "native/cluade: not for claude");
let changed = Note::SourceChanged {
location: Location::at_key("agentstacks.toml", "packs.core"),
};
assert_eq!(
changed.to_string(),
"agentstacks.toml: packs.core: source changed, resolved again"
);
Ok(())
}
}