use std::fmt;

use crate::makefile::command_line::CommandLine;

#[derive(PartialEq, Eq, Clone, Debug)]
pub(crate) struct InferenceRule {
    /// POSIX calls this ".s1" but that's not useful.
    pub(crate) product: String,
    /// POSIX calls this ".s2" but that's not useful.
    pub(crate) prereq: String,
    pub(crate) commands: Vec<CommandLine>,
}

impl fmt::Display for InferenceRule {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        writeln!(f, "{}{}:", &self.prereq, &self.product)?;
        for command in &self.commands {
            writeln!(f, "\t{}", command)?;
        }
        Ok(())
    }
}