use crate::report::{BadgeStyle, SeparatorStyle};
use clap::{ArgAction, ArgMatches, Command, arg, command};
pub const HELP_FILE: &str = r#"Coverage summary in JSON format"#;
pub const LONG_HELP_FILE: &str = r#"Coverage summary in JSON format.
With no FILE, or when FILE is -, read standard input.
To generate a coverage summary, use the following command:
cargo llvm-cov --json --summary-only"#;
pub const HELP_STYLE: &str = r#"Specify the badge style"#;
pub const LONG_HELP_STYLE: &str = r#"Specify the badge style.
Valid styles: 'flat', 'flat-square', 'plastic', 'for-the-badge', 'social'"#;
pub const HELP_LABEL: &str = r#"Specify the badge label"#;
pub const LONG_HELP_LABEL: &str = r#"Specify the badge label."#;
pub const HELP_SEPARATOR: &str = r#"Specify coverage value separator"#;
pub const LONG_HELP_SEPARATOR: &str = r#"Specify coverage value separator.
Valid separators: 'space', 'bar', 'spaced-bar'"#;
pub const HELP_NO_PERCENT_SIGN: &str = r#"Hide percent sign for coverage values"#;
pub const LONG_HELP_NO_PERCENT_SIGN: &str = r#"Hide percent sign for coverage values"#;
pub const HELP_SQUASH: &str = r#"Show one value when all equal"#;
pub const LONG_HELP_SQUASH: &str = r#"Show one value when all equal"#;
pub fn get_command() -> Command {
command!()
.arg(arg!(<FILE>).help(HELP_FILE).long_help(LONG_HELP_FILE).required(false).index(1))
.arg(
arg!(--"style" <STYLE>)
.short('s')
.help(HELP_STYLE)
.long_help(LONG_HELP_STYLE)
.required(false)
.action(ArgAction::Set)
.default_value("flat")
.display_order(1),
)
.arg(
arg!(--"label" <LABEL>)
.short('l')
.help(HELP_LABEL)
.long_help(LONG_HELP_LABEL)
.required(false)
.action(ArgAction::Set)
.default_value("cov")
.display_order(2),
)
.arg(
arg!(--"separator" <SEPARATOR>)
.short('r')
.help(HELP_SEPARATOR)
.long_help(LONG_HELP_SEPARATOR)
.required(false)
.action(ArgAction::Set)
.default_value("spaced-bar")
.display_order(3),
)
.arg(
arg!(--"no-percent-sign")
.short('n')
.help(HELP_NO_PERCENT_SIGN)
.long_help(LONG_HELP_NO_PERCENT_SIGN)
.required(false)
.action(ArgAction::SetTrue)
.display_order(4),
)
.arg(
arg!(--"squash")
.short('q')
.help(HELP_SQUASH)
.long_help(LONG_HELP_SQUASH)
.required(false)
.action(ArgAction::SetTrue)
.display_order(5),
)
.arg(
arg!(--"tag" <TAG>)
.short('t')
.help(HELP_SQUASH)
.long_help(LONG_HELP_SQUASH)
.required(false)
.action(ArgAction::Set)
.display_order(6),
)
.arg(
arg!(--"file" <FILE>)
.short('f')
.help(HELP_SQUASH)
.long_help(LONG_HELP_SQUASH)
.required(false)
.action(ArgAction::Set)
.display_order(7),
)
}
pub fn input_file(matches: &ArgMatches) -> Option<String> {
matches.get_one::<String>("FILE").cloned()
}
pub fn badge_style(matches: &ArgMatches) -> BadgeStyle {
matches.get_one::<String>("style").unwrap().as_str().into()
}
pub fn badge_label(matches: &ArgMatches) -> String {
matches.get_one::<String>("label").unwrap().to_string()
}
pub fn separator_style(matches: &ArgMatches) -> SeparatorStyle {
matches.get_one::<String>("separator").unwrap().as_str().into()
}
pub fn no_percent_sign(matches: &ArgMatches) -> bool {
matches.get_one::<bool>("no-percent-sign").unwrap().to_owned()
}
pub fn squash(matches: &ArgMatches) -> bool {
matches.get_one::<bool>("squash").unwrap().to_owned()
}
pub fn markdown_tag(matches: &ArgMatches) -> Option<String> {
matches.get_one::<String>("tag").cloned()
}
pub fn markdown_file(matches: &ArgMatches) -> Option<String> {
matches.get_one::<String>("file").cloned()
}