Add config printing, explain mode, completions, and docs
This commit is contained in:
33
src/main.rs
33
src/main.rs
@@ -11,9 +11,10 @@ mod report;
|
||||
mod utils;
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use clap::{CommandFactory, Parser};
|
||||
use clap_complete::{generate, Shell};
|
||||
|
||||
use crate::cli::Cli;
|
||||
use crate::cli::{Cli, CompletionShell};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
if std::env::args_os().len() == 1 {
|
||||
@@ -23,12 +24,38 @@ fn main() -> Result<()> {
|
||||
}
|
||||
|
||||
let cli = Cli::parse();
|
||||
|
||||
if let Some(shell) = cli.completions.clone() {
|
||||
let mut cmd = Cli::command();
|
||||
let shell = match shell {
|
||||
CompletionShell::Bash => Shell::Bash,
|
||||
CompletionShell::Zsh => Shell::Zsh,
|
||||
CompletionShell::Fish => Shell::Fish,
|
||||
};
|
||||
generate(shell, &mut cmd, "mov-renamarr", &mut std::io::stdout());
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let settings = config::build_settings(&cli)?;
|
||||
|
||||
if cli.print_config {
|
||||
let rendered = config::format_settings(&settings)?;
|
||||
println!("{rendered}");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let report_format = settings.report_format.clone();
|
||||
let report_path = settings.report_path.clone();
|
||||
let dry_run_summary = settings.dry_run_summary;
|
||||
|
||||
let report = pipeline::run(settings)?;
|
||||
report.write(&report_format, report_path.as_deref())?;
|
||||
if dry_run_summary
|
||||
&& report_path.is_none()
|
||||
&& matches!(report_format, crate::cli::ReportFormat::Text)
|
||||
{
|
||||
report.write_summary(None)?;
|
||||
} else {
|
||||
report.write(&report_format, report_path.as_deref())?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user