1pub(crate) mod diff;
4pub(crate) mod lint_markers;
5
6use anyhow::Result;
7use clap::{Parser, Subcommand};
8
9#[derive(Parser)]
11pub struct CoverageCommand {
12 #[command(subcommand)]
14 pub command: CoverageSubcommands,
15
16 #[command(flatten)]
18 pub repo: crate::cli::repo_arg::RepoArg,
19}
20
21#[derive(Subcommand)]
23pub enum CoverageSubcommands {
24 Diff(Box<diff::DiffCommand>),
26 LintMarkers(lint_markers::LintMarkersCommand),
28}
29
30impl CoverageCommand {
31 pub fn execute(self) -> Result<()> {
36 let repo = self.repo.path();
37 match self.command {
38 CoverageSubcommands::Diff(cmd) => cmd.execute(repo),
39 CoverageSubcommands::LintMarkers(cmd) => cmd.execute(repo),
40 }
41 }
42}
43
44#[cfg(test)]
45#[allow(clippy::unwrap_used, clippy::expect_used)]
46mod tests {
47 use super::*;
48
49 #[test]
52 fn dispatches_to_diff() {
53 let cmd = CoverageCommand {
54 command: CoverageSubcommands::Diff(Box::new(diff::DiffCommand {
55 report: vec![std::path::PathBuf::from("/nonexistent/report.lcov")],
56 report_format: diff::ReportFormat::Auto,
57 base_ref: Some("HEAD".to_string()),
58 head_ref: None,
59 baseline_report: None,
60 baseline_report_format: diff::ReportFormat::Auto,
61 output: diff::OutputFormatArg::Markdown,
62 format: None,
63 fail_under_patch: None,
64 fail_under_lines: None,
65 strip_prefix: None,
66 ignore_filename_regex: Vec::new(),
67 context_dir: None,
68 collapse_ranges: false,
69 all_files: false,
70 artifact_url: None,
71 run_url: None,
72 base_sha: None,
73 head_sha: None,
74 commit_url: None,
75 })),
76 repo: crate::cli::repo_arg::RepoArg::default(),
77 };
78 assert!(cmd.execute().is_err());
80 }
81}