use anyhow::Result;
use bytesize::ByteSize;
use tracing::{debug, Level};
use tracing_subscriber::fmt;
use yek::{config::YekConfig, serialize_repo};
fn main() -> Result<()> {
let full_config = YekConfig::init_config();
fmt::Subscriber::builder()
.with_max_level(if full_config.debug {
Level::DEBUG
} else {
Level::INFO
})
.with_target(false)
.with_thread_ids(false)
.with_thread_names(false)
.with_file(false)
.with_line_number(false)
.with_level(true)
.with_env_filter("yek=debug,ignore=off")
.compact()
.init();
if full_config.debug {
let config_str = serde_json::to_string_pretty(&full_config)?;
debug!("Configuration:\n{}", config_str);
}
let (output, files) = serialize_repo(&full_config)?;
if full_config.stream {
println!("{}", output);
} else {
if full_config.debug {
let size = ByteSize::b(output.len() as u64);
debug!("{} files processed", files.len());
debug!("{} generated", size); debug!("{} lines generated", output.lines().count());
}
println!("{}", full_config.output_file_full_path);
}
Ok(())
}