64 lines
1.7 KiB
Rust
64 lines
1.7 KiB
Rust
use std::path::PathBuf;
|
|
|
|
use chrono::{Duration, Local};
|
|
use clap::{Parser, ValueHint, arg};
|
|
|
|
use crate::heatmap::{ColorLogic, Format, HeatmapColors};
|
|
|
|
#[derive(Clone, Default, Debug, Parser, PartialEq, Eq)]
|
|
#[command(version, about, author, long_about = None, args_override_self = true)]
|
|
pub struct CliArgs {
|
|
#[arg(long("root-dir"), value_hint = ValueHint::DirPath)]
|
|
pub root_dir: Option<Vec<PathBuf>>,
|
|
|
|
#[arg(short, long, num_args(0..))]
|
|
pub authors: Option<Vec<String>>,
|
|
|
|
#[arg(short, long, default_value = "▩")]
|
|
pub char: char,
|
|
|
|
#[arg(long("color"), value_enum, default_value_t = HeatmapColors::Green)]
|
|
pub color_scheme: HeatmapColors,
|
|
|
|
#[arg(short, long, num_args(0..), value_hint = ValueHint::DirPath)]
|
|
pub repos: Option<Vec<PathBuf>>,
|
|
|
|
#[arg(short('i'), long("ignore"), num_args(0..))]
|
|
pub ignored_repos: Option<Vec<String>>,
|
|
|
|
#[arg(short, long, num_args(0..))]
|
|
pub branches: Option<Vec<String>>,
|
|
|
|
#[arg(long("since"), default_value_t = get_since_date())]
|
|
pub since: String,
|
|
|
|
#[arg(long("until"))]
|
|
pub until: Option<String>,
|
|
|
|
#[arg(long("split-months"), help("Split months"), default_value_t = false)]
|
|
pub split_months: bool,
|
|
|
|
#[arg(
|
|
long("months-per-row"),
|
|
help("Wrap the months on a new row"),
|
|
default_value_t = 13
|
|
)]
|
|
pub months_per_row: u16,
|
|
|
|
#[arg(long("no-merges"), default_value_t = false)]
|
|
pub no_merges: bool,
|
|
|
|
#[arg(long("counting"), value_enum, default_value_t = ColorLogic::ByWeight)]
|
|
pub counting: ColorLogic,
|
|
|
|
#[arg(short, long("format"), value_enum, default_value_t = Format::Chars)]
|
|
pub format: Format,
|
|
|
|
#[arg(long("list-repos"), default_value_t = false)]
|
|
pub list_repos: bool,
|
|
}
|
|
|
|
fn get_since_date() -> String {
|
|
let date = Local::now() - Duration::days(365);
|
|
date.format("%Y-%m-%d").to_string()
|
|
} |