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 output: diff::OutputFormatArg::Markdown,
53 format: None,
54 fail_under_patch: None,
55 strip_prefix: None,
56 collapse_ranges: false,
57 all_files: false,
58 artifact_url: None,
59 run_url: None,
60 base_sha: None,
61 head_sha: None,
62 commit_url: None,
63 }),
64 };
65 assert!(cmd.execute(None).await.is_err());
67 }
68}