Added today keyword for the until flag
parent
8f4a8c18f9
commit
1d97cbfa45
|
|
@ -84,5 +84,6 @@ $ git-heatmap -a "username" -a "other"
|
|||
$ git-heatmap --since "2013-08-23"
|
||||
|
||||
# or choose a time span, both --since and --until must use a YYYY-MM-DD format
|
||||
# --until can optionally use `today` as a keyword for the current date
|
||||
$ git-heatmap --since "2013-08-23" --until "2024-08-23"
|
||||
```
|
||||
|
|
|
|||
|
|
@ -32,7 +32,12 @@ pub struct CliArgs {
|
|||
#[arg(long("since"), default_value_t = get_since_date())]
|
||||
pub since: String,
|
||||
|
||||
#[arg(long("until"))]
|
||||
#[arg(
|
||||
long("until"),
|
||||
help(
|
||||
"Optional upper limit for the time slice being checked, defaults to 365 days after the `since` date.\n`today` can be used for current date."
|
||||
)
|
||||
)]
|
||||
pub until: Option<String>,
|
||||
|
||||
#[arg(long("split-months"), help("Split months"), default_value_t = false)]
|
||||
|
|
@ -74,4 +79,4 @@ pub struct CliArgs {
|
|||
fn get_since_date() -> String {
|
||||
let date = Local::now() - Duration::days(364);
|
||||
date.format("%Y-%m-%d").to_string()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@ fn main() -> Result<()> {
|
|||
.until
|
||||
.clone()
|
||||
.unwrap_or_else(|| libgitheatmap::get_default_until(since));
|
||||
let until = NaiveDate::parse_from_str(&until, "%Y-%m-%d").unwrap();
|
||||
let until = match until.to_lowercase().as_str() {
|
||||
"today" => chrono::Local::now().date_naive(),
|
||||
_ => NaiveDate::parse_from_str(&until, "%Y-%m-%d").unwrap(),
|
||||
};
|
||||
|
||||
let split_months = args.split_months;
|
||||
let months_per_row = args.months_per_row;
|
||||
|
|
|
|||
Loading…
Reference in New Issue