use std::path::PathBuf;

use super::Pipeline;

/// A resolved job reference that may point into a child pipeline.
///
/// Used by `--run`, `--container`, and `--dump-script` to locate a job
/// across the root pipeline and any child/trigger pipelines.
pub struct ResolvedJob {
    pub child_pipeline: Option<Pipeline>,
    pub job_name: String,
    pub file_path: PathBuf,
}

impl ResolvedJob {
    pub fn pipeline<'a>(&'a self, root: &'a Pipeline) -> &'a Pipeline {
        self.child_pipeline.as_ref().unwrap_or(root)
    }
}
