use crate::config::get_config;
use crate::utils::read_and_print;

/// Reads and prints the local SlackBuilds.org ChangeLog.txt.
///
/// If `filter` is non-empty, only lines containing at least one of the given strings
/// are printed. If `filter` is empty, the full `ChangeLog` is printed.
///
/// # Arguments
///
/// * `filter` - List of strings to narrow the output; when empty the full file is shown.
///
/// # Exits
///
/// Exits with code 1 if the changelog file is not found in the configured repository path.
pub fn changelog(filter: &[String]) {
    let cfg = get_config();
    let filename = format!("{}/{}", cfg.repo_path, cfg.changelog);
    read_and_print(&filename, Some(filter));
}
