use crate::filter::DistributionFilter;

/// Settings struct to configure how a [Distribution](crate::Distribution) is built.
#[derive(Default)]
pub struct DistributionOptions {
    /// Build a partial distribution with only those subpaths of the distribution included that match the provided filter.
    ///
    /// The filter can be set to `Disabled` to include all paths.
    /// If it's set to `Enabled` instead, you need to provide 1 or more path prefixes,
    /// which will be matched against the subpaths relative to the distribution root.
    ///
    /// ```no_run
    ///# use std::path::PathBuf;
    ///# use cicero_distribution::{bundle::dir::DirBundler, Distribution, DistributionOptions, filter};
    ///#
    ///# fn main() -> cicero_core::Result<()> {
    ///# let favicon_path = PathBuf::from("favicon.png");
    /// let filter = filter::DistributionFilter::Enabled(vec![filter::Pattern::new("public")?]);
    ///
    /// let distribution = Distribution::new_with_options(
    ///     "my_app",
    ///     DistributionOptions { filter },
    /// )?;
    ///
    /// distribution.dir("public")?
    ///     .add_file("favicon.png", |path| unimplemented!("copy file to path"));
    ///
    /// distribution.dir("something_else")?;
    ///
    /// let out_dir = distribution.bundle(DirBundler); //will not contain "something_else", only "public/favicon.png"
    ///#
    ///# Ok(())
    ///# }
    /// ```
    ///
    /// This filtering is useful in particular for CI/CD runners, where you may want to build the
    /// distribution in multiple steps to utilize the CI/CD runner's caching and parallel execution.
    /// To do so, expose a `--filter` flag as part of your CLI, which you then parametrize in the scripts that your CI/CD runner executes.
    pub filter: DistributionFilter,
}
