diff options
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r-- | cli/args/flags.rs | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 1acef2058..2eed2a183 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -85,12 +85,19 @@ pub struct CompletionsFlags { } #[derive(Clone, Debug, Eq, PartialEq)] +pub enum CoverageType { + Pretty, + Lcov, + Html, +} + +#[derive(Clone, Debug, Eq, PartialEq)] pub struct CoverageFlags { pub files: FileFlags, pub output: Option<PathBuf>, pub include: Vec<String>, pub exclude: Vec<String>, - pub lcov: bool, + pub r#type: CoverageType, } #[derive(Clone, Debug, Eq, PartialEq)] @@ -1398,6 +1405,14 @@ Generate html reports from lcov: .value_hint(ValueHint::FilePath), ) .arg( + Arg::new("html") + .long("html") + .help( + "Output coverage report in HTML format in the given directory", + ) + .action(ArgAction::SetTrue), + ) + .arg( Arg::new("files") .num_args(1..) .value_parser(value_parser!(PathBuf)) @@ -3298,7 +3313,13 @@ fn coverage_parse(flags: &mut Flags, matches: &mut ArgMatches) { Some(f) => f.collect(), None => vec![], }; - let lcov = matches.get_flag("lcov"); + let r#type = if matches.get_flag("lcov") { + CoverageType::Lcov + } else if matches.get_flag("html") { + CoverageType::Html + } else { + CoverageType::Pretty + }; let output = matches.remove_one::<PathBuf>("output"); flags.subcommand = DenoSubcommand::Coverage(CoverageFlags { files: FileFlags { @@ -3308,7 +3329,7 @@ fn coverage_parse(flags: &mut Flags, matches: &mut ArgMatches) { output, include, exclude, - lcov, + r#type, }); } @@ -7867,7 +7888,7 @@ mod tests { output: None, include: vec![r"^file:".to_string()], exclude: vec![r"test\.(js|mjs|ts|jsx|tsx)$".to_string()], - lcov: false, + r#type: CoverageType::Pretty }), ..Flags::default() } @@ -7893,7 +7914,7 @@ mod tests { }, include: vec![r"^file:".to_string()], exclude: vec![r"test\.(js|mjs|ts|jsx|tsx)$".to_string()], - lcov: true, + r#type: CoverageType::Lcov, output: Some(PathBuf::from("foo.lcov")), }), ..Flags::default() |