licenses 0.6.0

Cargo subcommand for collecting licenses.
use colored::Colorize;

pub fn warning(message: &str) -> String {
    format!("{}: {}", "warning".yellow().bold(), message)
}

pub fn progress_bar(msg: &str) -> indicatif::ProgressBar {
    indicatif::ProgressBar::new(0)
        .with_style(
            #[allow(clippy::literal_string_with_formatting_args)]
            indicatif::ProgressStyle::with_template("{spinner} {msg}...\n{wide_bar} {pos}/{len}")
                .expect("invalid progress bar style"),
        )
        .with_message(msg.to_owned())
}

#[cfg_attr(test, autospy::autospy)]
pub trait ProgressBar {
    fn set_len(&self, len: u64);
    fn increment(&self);
    fn finish(&self);
}

impl ProgressBar for indicatif::ProgressBar {
    fn set_len(&self, len: u64) {
        self.set_length(len);
    }
    fn increment(&self) {
        self.inc(1);
    }
    fn finish(&self) {
        self.finish_and_clear();
    }
}