1pub(crate) mod diff;
4
5use anyhow::Result;
6use clap::{Parser, Subcommand};
7
8#[derive(Parser)]
10pub struct CoverageCommand {
11 #[command(subcommand)]
13 pub command: CoverageSubcommands,
14}
15
16#[derive(Subcommand)]
18pub enum CoverageSubcommands {
19 Diff(diff::DiffCommand),
21}
22
23impl CoverageCommand {
24 pub async fn execute(self, repo: Option<&std::path::Path>) -> Result<()> {
29 match self.command {
30 CoverageSubcommands::Diff(cmd) => cmd.execute(repo).await,
31 }
32 }
33}
34
35#[cfg(test)]
36#[allow(clippy::unwrap_used, clippy::expect_used)]
37mod tests {
38 use super::*;
39
40 #[tokio::test]
43 async fn dispatches_to_diff() {
44 let cmd = CoverageCommand {
45 command: CoverageSubcommands::Diff(diff::DiffCommand {
46 report: std::path::PathBuf::from("/nonexistent/report.lcov"),
47 report_format: diff::ReportFormat::Auto,
48 base_ref: Some("HEAD".to_string()),
49 head_ref: None,
50 baseline_report: None,
51 baseline_report_format: diff::ReportFormat::Auto,
52 format: diff::OutputFormatArg::Markdown,
53 fail_under_patch: None,
54 strip_prefix: None,
55 collapse_ranges: false,
56 all_files: false,
57 artifact_url: None,
58 run_url: None,
59 base_sha: None,
60 head_sha: None,
61 commit_url: None,
62 }),
63 };
64 assert!(cmd.execute(None).await.is_err());
66 }
67}