use crate::shell::{CommandOutput, Shell};
impl Shell {
pub fn cmd_source(&self, args: &[&str]) -> CommandOutput {
let file = match args.first() {
Some(f) => *f,
None => return CommandOutput::error("source: missing file operand\n".to_string(), 1),
};
let _resolved = match self.vfs.resolve(file, &self.cwd) {
Ok(p) => p,
Err(e) => return CommandOutput::error(format!("source: {}: {}\n", file, e), 1),
};
let content = match self.read_text_lossy(file) {
Ok(c) => c,
Err(e) => return CommandOutput::error(format!("source: {}: {}\n", file, e), 1),
};
CommandOutput::success(content)
}
}