Cal improvements (#2074)

* .get() already checks for the argument, don't need to use .has() as well

* Supplying the month-names flag should also cause the months column to show up, it should not require the -m flag first
This commit is contained in:
Joseph T. Lyons 2020-06-28 13:16:10 -04:00 committed by GitHub
parent 8d91d151bf
commit 3f170c7fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,17 +84,15 @@ pub async fn cal(
let mut selected_year: i32 = current_year;
let mut current_day_option: Option<u32> = Some(current_day);
let month_range = if args.has("full-year") {
if let Some(full_year_value) = args.get("full-year") {
if let Ok(year_u64) = full_year_value.as_u64() {
selected_year = year_u64 as i32;
let month_range = if let Some(full_year_value) = args.get("full-year") {
if let Ok(year_u64) = full_year_value.as_u64() {
selected_year = year_u64 as i32;
if selected_year != current_year {
current_day_option = None
}
} else {
return Err(get_invalid_year_shell_error(&full_year_value.tag()));
if selected_year != current_year {
current_day_option = None
}
} else {
return Err(get_invalid_year_shell_error(&full_year_value.tag()));
}
(1, 12)
@ -300,7 +298,7 @@ fn add_month_to_table(
);
}
if should_show_month_column {
if should_show_month_column || should_show_month_names {
let month_value = if should_show_month_names {
UntaggedValue::string(month_helper.month_name.clone()).into_value(tag)
} else {