use crate::aaml::AAML;
use crate::commands::Command;
use crate::error::AamlError;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ImportCommand;
impl Command for ImportCommand {
fn name(&self) -> &str {
"import"
}
fn execute(&self, aaml: &mut AAML, args: &str) -> Result<(), AamlError> {
let raw_path = args.trim();
if raw_path.is_empty() {
return Err(AamlError::ParseError {
line: 0,
content: args.to_string(),
details: "Import path cannot be empty".to_string(),
diagnostics: Some(crate::error::ErrorDiagnostics::new(
"Missing import path",
"@import directive requires a file path",
"Use format: @import \"path/to/file.aam\"",
)),
});
}
let path = AAML::unwrap_quotes(raw_path);
aaml.merge_file(path)
}
}